Created
August 17, 2012 12:11
-
-
Save Asmageddon/3378355 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| static value random_int( value o, value max ) { | |
| if (!val_is_int(max)) {fprintf(stderr,"std_random max is no int\n");} | |
| else {fprintf(stderr,"std_random max is in fact an int\n");} | |
| if (!val_is_int(o)) {fprintf(stderr,"std_random o is no int\n");} | |
| else {fprintf(stderr,"std_random o is in fact an int\n");} | |
| val_check_kind(o,k_random); | |
| val_check(max,int); | |
| if( val_int(max) <= 0 ) | |
| return alloc_int(0); | |
| return alloc_int( (rnd_int(val_rnd(o)) & 0x3FFFFFFF) % val_int(max) ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment