Branch: Tag:

2016-03-16

2016-03-16 13:27:13 by Arne Goedeke <el@laramies.com>

RandomInterface: fixed random(float f)

random_float always returned 0.0. Also: use a random unsigned INT64
to avoid negative results.

2146:    PIKEFUN float random(float f)    {    if(f<=0.0) RETURN 0.0; -  INT64 value; - #if SIZEOF_INT_TYPE > 4 -  value = read_int(0xffffffffffffffff); - #else -  value = read_int(0xffffffff) << 32 | read_int(0xffffffff); - #endif +  unsigned INT64 value; +  if (THIS->buffer_bits < 64) +  fill_int_buffer(); +  value = THIS->int_buffer; +  THIS->buffer_bits = 0; +     RETURN (FLOAT_TYPE)ldexp((double)f * value, -64);    }