Branch: Tag:

2015-09-15

2015-09-15 23:26:19 by Henrik Grubbström (Grubba) <grubba@grubba.org>

random(): Subtle change in range of random(float).

random(float) should now have the full range 0.0 <= res < arg again.

Also improves significant bits of the mantissa on 64-bit architectures,
and performance by avoiding a division.

2108:   {    if(f<=0.0) RETURN 0.0;    - #define MASK ((1L<<32)-1) -  RETURN (float)(f * (((my_rand()&MASK)-1) / (double)MASK)); +  RETURN (FLOAT_TYPE)ldexp((double)f * my_rand64(), -64);   }      /*! @decl mixed random(array|multiset x)