Search found 2770 matches

by MrSwiss
Oct 30, 2018 18:55
Forum: General
Topic: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)
Replies: 106
Views: 1559

Re: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)

deltarho[1859] wrote:In fact the first table is MrSWiss' figures
Just so much:
they're NOT my figures, my figures are Doubles ...
by MrSwiss
Oct 30, 2018 16:31
Forum: General
Topic: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)
Replies: 106
Views: 1559

Re: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)

@deltarho[], The proposed Function (Double range) is, by your own Standards: NOK! Due to 'equal distribution' failure ... (Banker's rounding). In any case, I'd use a #Define: ' range: -/+ OK, +/+ OK, 0.0/+ OK, -/0.0 NOK, -/- NOK || distribution OK #Define D_Rng(l, h) ( Int(Rnd() * ((h+1) - (l)) + (l...
by MrSwiss
Oct 30, 2018 1:22
Forum: General
Topic: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)
Replies: 106
Views: 1559

Re: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)

I expect your code to compete with mine.
Yet another wrong expectation ...
(you do your thing and, I do mine)
IMO, signed range isn't wanted, nor useful (most generators, incl. PCG32 use unsigned only).
by MrSwiss
Oct 30, 2018 0:46
Forum: General
Topic: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)
Replies: 106
Views: 1559

Re: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)

Added: BTW, your code will not handle a signed range.

What did you expect with CULngInt(), you surely must be joking!
by MrSwiss
Oct 29, 2018 23:19
Forum: General
Topic: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)
Replies: 106
Views: 1559

Re: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)

31 bit granularity? You obviously don't read posts carefully, or understand them well. Reread my previous post, stating that: the problem (31 bit) is with FBC 32, and doesn't apply in FBC 64!!! It seems that you have a problem admitting you made a mistake. That has never bothered me. Best laugh I'v...
by MrSwiss
Oct 29, 2018 22:28
Forum: General
Topic: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)
Replies: 106
Views: 1559

Re: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)

My case is your CULngInt suggestion still rounded up ??? I don't care which way it rounds (in my case probably both ways), the results matter: 0 9092543 1 9089030 2 9090667 3 9091446 4 9093429 5 9093451 6 9091621 7 9093796 8 9093080 9 9084842 10 9086095 to high: 0 to low: 0 count: 100000000 out of ...
by MrSwiss
Oct 29, 2018 21:33
Forum: General
Topic: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)
Replies: 106
Views: 1559

Re: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)

On an elegance scale of 10: MrSwiss 1; Deltarho 7 On an efficency scale of 10: MrSwiss 10; Deltarho 3 (none ?? duno) I don't code, to win elegance competitions (I want correctly working code). You mean as you did when you suggested CULngInt. What's your case? That problem was easily solved! (with i...
by MrSwiss
Oct 29, 2018 20:11
Forum: General
Topic: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)
Replies: 106
Views: 1559

Re: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)

Bit of a can of worms - I didn't expect this. <smile> Seems to be a matter of underestimating the problem. Btw: Int() produces at maximum, a Double with 31 bit granularity (bad news!). FBC 32. No such problem with FBC 64. The better way, to deal with it is IMO, to resolve rounding of ULongInt (inst...
by MrSwiss
Oct 29, 2018 15:49
Forum: General
Topic: Converting code to FreeBasic help
Replies: 17
Views: 326

Re: Converting code to FreeBasic help

As a first step, use the correct data-types:

int (in C) = Long (in FB) and NOT: integer

See: TblComparisonC in FB-Manual.
by MrSwiss
Oct 29, 2018 14:20
Forum: Tips and Tricks
Topic: 3 Concepts, same Result
Replies: 32
Views: 1001

Re: 3 Concepts, same Result

My preferred method, more versatile and better readable, without Pointers: #Define blue_cc(src) ( CUByte(src) ) ' get blue color channel #Define green_cc(src) ( CUByte((src) Shr 8) ) ' get green color channel #Define red_cc(src) ( CUByte((src) Shr 16) ) ' get red color channel #Define alpha_cc(src) ...
by MrSwiss
Oct 29, 2018 12:11
Forum: General
Topic: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)
Replies: 106
Views: 1559

Re: Bernard Widynski's Middle Square Weyl Sequence RNG (MsWs)

Revised to 'Function = Int(This.Seed/2^64*( Last - First + 1) + First)' gives a balanced distribution. The disribution problem relates to: Int() 's rounding preference. This is the reason that I'm only using: CInt() (never Int()) but this creates another problem: Integer = a Long in FBC 32, or a Lo...
by MrSwiss
Oct 27, 2018 20:29
Forum: Tips and Tricks
Topic: Simple Smoke Simulation build 2018-11-02
Replies: 10
Views: 281

Re: Simple Smoke Simulation build 2018-10-26

@dodicat, looks cool. Congrats to your birthday (yesterday), many happy returns. Better late, than never ... Also proof, that ASM makes little sense, these days (compatibility issues among many others). All the ASM dependent BASIC-Compilers, are on the way out ... (PB, e.t.c.) because, nobody wants ...
by MrSwiss
Oct 26, 2018 11:49
Forum: Tips and Tricks
Topic: 3 Concepts, same Result
Replies: 32
Views: 1001

Re: 3 Concepts, same Result

Seems to me, to be a mixup between:
Declare -- a byref variable (my reference)
Passing method (of variables) to procedures (NOT the same thing!)
by MrSwiss
Oct 26, 2018 11:22
Forum: Tips and Tricks
Topic: 3 Concepts, same Result
Replies: 32
Views: 1001

Re: 3 Concepts, same Result

A ByRef variable is in fact, just a hidden, dereferenced Ptr. (this is the way, FB handles it, behind the scenes) Your #Define uses a: dereferenced Ptr (after casting it, to a different type). (more or less the same, as the pointer concept, used by myself in first post) It always boils down to a few...
by MrSwiss
Oct 25, 2018 22:17
Forum: Tips and Tricks
Topic: 3 Concepts, same Result
Replies: 32
Views: 1001

Re: 3 Concepts, same Result

Why not simply a Union, as below ... Union _32_bit As Long l As ULong u As Single s End Union Dim As _32_bit unn Print "Long", "ULong", "Single" Print String(42, "~") For f As Single = -0.12 To -0.26 Step -0.01 unn.s = f Print unn.l, unn.u, unn.s Next Print : ...

Go to advanced search