Branch: Tag:

2015-11-15

2015-11-15 00:34:36 by Martin Nilsson <nilsson@fastmail.com>

Moved the range limiting of random numbers into my_rand(64).

2088:    if(i <= 0) RETURN 0;   #if SIZEOF_INT_TYPE > 4    if(i >> 31) -  RETURN my_rand64() % i; +  RETURN my_rand64(i);   #endif -  RETURN my_rand() % i; +  RETURN my_rand(i);   }      /*! @decl float random(float max)
2106:   {    if(f<=0.0) RETURN 0.0;    -  RETURN (FLOAT_TYPE)ldexp((double)f * my_rand64(), -64); +  RETURN (FLOAT_TYPE)ldexp((double)f * my_rand64(0), -64);   }      /*! @decl mixed random(array|multiset x)
2119:   {    if(!a->size)    SIMPLE_BAD_ARG_ERROR("random", 1, "array with elements in it"); -  push_svalue(a->item + (my_rand() % a->size)); +  push_svalue(a->item + (my_rand(a->size)));    stack_swap();    pop_stack();   }
2130:   {    if(multiset_is_empty (m))    SIMPLE_BAD_ARG_ERROR("random", 1, "multiset with elements in it"); -  push_multiset_index (m, multiset_get_nth (m, my_rand() % -  multiset_sizeof (m))); +  push_multiset_index (m, multiset_get_nth (m, my_rand(multiset_sizeof (m))));    sub_msnode_ref (m);    stack_swap();    pop_stack();
2152:    SIMPLE_BAD_ARG_ERROR("random", 1, "mapping with elements in it");       /* Find a random, nonempty bucket */ -  bucket=my_rand() % md->hashsize; +  bucket=my_rand(md->hashsize);    while(! md->hash[bucket] )    if(++bucket > (size_t)md->hashsize)    bucket=0;
2162:    for(k=md->hash[bucket];k;k=k->next) count++;       /* Select a random entry in this bucket */ -  count = my_rand() % count; +  count = my_rand(count);    k=md->hash[bucket];    while(count-- > 0) k=k->next;