* Added ikrt_fxrandom function to the runtime system.

This commit is contained in:
Abdulaziz Ghuloum 2007-08-30 21:44:52 -04:00
parent eabfc3fe4f
commit fc06fa7312
2 changed files with 18 additions and 0 deletions

Binary file not shown.

View File

@ -1273,3 +1273,21 @@ ikrt_bignum_to_bytevector(ikp x, ikpcb* pcb){
return bv + bytevector_tag;
}
ikp
ikrt_fxrandom(ikp x){
int mask = 1;
int n = unfix(x);
{
while(mask < n){
mask = (mask << 1) | 1;
}
}
while(1){
long r = random() & mask;
if(r < n){
return fix(r);
}
}
}