Hi Christophe,

> That the results are analog, but different. To obtain exactly the same
> results that pil32,
> I had to write:
> seed ()
>     long n = (Seed = initSeed(ex.Cdr.Car.eval()) * 6364136223846793005L) >>> 
> 32;
>     return new Number(n%2==0 ? n/2 : -(n-1)/2);

Is it really so important that the random generators give the same

I had never intended that. The reason is that the random generator
should be as simple (fast) as possible, and all four implementations
represent numbers differently:

1. pil32 has only bignums, where the random generator restricts itself
   to a single cell. Each bignum cell can hold 32 bits, where the sign
   bit is in bit 0 (no two's complement!). Therefore, the value is
   multiplied by 2, and the sign bit is added.

2. pil64 has bignums with 64 bits in each cell, and short numbers with
   60 bits plus a sign bit in bit 3 (bits 0 - 2 are tag bits). Random
   numbers are placed into short numbers.

3. miniPicoLisp has only short numbers (in two's complement, either 30
   bit on 32-bit machines, or 62 bits on 64-bit machines including the

4. Ersatz uses BigIntegers for bignums, and 'int's for short numbers.
   Thus, a random number is a two's complement 32-bit integer.

So there is no "natural" way to get completely equal results.

♪♫ Alex
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe

Reply via email to