mirror of
https://github.com/rfivet/uemacs.git
synced 2024-11-17 18:16:22 -05:00
Avoid 176719 periodicity of &rnd 0.
This commit is contained in:
parent
9b1c5f48a2
commit
83b4028c95
9
eval.c
9
eval.c
@ -537,11 +537,11 @@ static char *gtfun( char *fname) {
|
||||
retstr = result ;
|
||||
break ;
|
||||
case UFRND | MONAMIC:
|
||||
sz = abs( atoi( arg1)) ;
|
||||
sz = atoi( arg1) ;
|
||||
if( sz == 0)
|
||||
sz = ernd() ;
|
||||
else
|
||||
sz = ernd() % sz + 1 ;
|
||||
sz = ernd() % abs( sz) + 1 ;
|
||||
|
||||
retstr = i_to_a( sz) ;
|
||||
break ;
|
||||
@ -1323,8 +1323,9 @@ int abs(int x)
|
||||
* returns a random integer
|
||||
*/
|
||||
static int ernd( void) {
|
||||
seed = abs(seed * 1721 + 10007);
|
||||
return seed;
|
||||
seed = seed * 1721 + 10007 ;
|
||||
seed &= ~(1 << 31) ; /* abs() introduces 176719 periodicity */
|
||||
return seed ;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user