[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gforth] how to build a really working random seed ?

From: Andrew Haley
Subject: Re: [gforth] how to build a really working random seed ?
Date: Mon, 17 Jul 2017 09:10:54 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.1.0

On 16/07/17 17:16, Francois Pussault wrote:

> this fucking bullshit proc├ędure make only zero's ....But what I need
> is a -1/0 ending state (on/off) or similar what I misunderstood ?

The xor-shift generator produces a full cycle of every bit patter
except all zeroes: that is to say, zero is not prt of its sequence.
You need to start with a nonzero value.

If you can't exclude that possibility, do this:

: rnd ( -- n)
        (rnd) @  dup 0= or
        dup 13 lshift xor
        dup 17 rshift xor
        dup DUP 5 lshift xor (rnd) !

Andrew Haley

reply via email to

[Prev in Thread] Current Thread [Next in Thread]