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