pike.git
/
src
/
builtin.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/builtin.cmod:1:
/* -*- c -*- || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
-
|| $Id: builtin.cmod,v 1.
255
2010/03/
03
16
:
31
:
05
srb
Exp $
+
|| $Id: builtin.cmod,v 1.
256
2010/03/
23
12
:
24
:
01
grubba
Exp $
*/ #include "global.h" #include "interpret.h" #include "svalue.h" #include "pike_macros.h" #include "object.h" #include "program.h" #include "array.h" #include "pike_error.h"
pike.git/src/builtin.cmod:1356:
*! This function returns a random number in the range 0 - @[max]-1. *! *! @seealso *! @[random_seed()] */ PMOD_EXPORT PIKEFUN int random(int i) { if(i <= 0) RETURN 0;
+
#ifdef AUTO_BIGNUM
+
if(i >> 31) {
+
unsigned INT_TYPE a = my_rand();
+
unsigned INT_TYPE b = my_rand();
+
RETURN (INT_TYPE)(((a<<32)|b) % i);
+
}
+
#endif
RETURN my_rand() % i; } PMOD_EXPORT PIKEFUN float random(float f) { if(f<=0.0) RETURN 0.0; #define N 1048576 RETURN f * (my_rand()%N/((float)N)) + f * (my_rand()%N/( ((float)N) * ((float)N) ));