pike.git
/
src
/
builtin.cmod
version
»
Context lines:
10
20
40
80
file
none
3
pike.git/src/builtin.cmod:1:
-
/* -*- c -*-
+
/* -*-
mode:
c
;
encoding: utf
-
8; -
*-
|| 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. */ #include "global.h" #include "interpret.h" #include "svalue.h" #include "pike_macros.h" #include "object.h"
pike.git/src/builtin.cmod:2069:
int f = low_find_lfun(o->prog, LFUN__RANDOM); if (f < 0) { Pike_error("Calling undefined lfun::%s.\n", lfun_names[LFUN__RANDOM]); } apply_low(o, f, 0); stack_swap(); pop_stack(); } /*! @decl int random(int max)
-
*! @decl float random(float max)
+
*!
-
*! This function returns a random number in the range
0
-
@[max]-
1
.
+
*! This function returns a random number in the range
@expr{0
..
@[max]-
1@}
.
*! *! @seealso *! @[random_seed()] */
-
+
/*! @decl float random(float max)
+
*!
+
*! This function returns a random number in the range @expr{0 .. @[max]-ɛ@}.
+
*!
+
*! @seealso
+
*! @[random_seed()]
+
*/
+
PMOD_EXPORT PIKEFUN int random(int i) { if(i <= 0) RETURN 0; #if SIZEOF_INT_TYPE > 4 if(i >> 31) { unsigned INT_TYPE a = my_rand(); unsigned INT_TYPE b = my_rand(); RETURN (INT_TYPE)(((a<<32)|b) % i); }