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.
147
2004/
02
/
13
23
:
09
:
25
nilsson Exp $
+
|| $Id: builtin.cmod,v 1.
148
2004/
03/
02
20
:
45
:
22
nilsson 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:1092:
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) )); }
-
/*! @decl mixed random(array|multiset
xa
)
+
/*! @decl mixed random(array|multiset
x
)
*! Returns a random element from @[x]. */ PIKEFUN mixed random(array a) rawtype tFunc(tArr(tSetvar(0,tMix)),tVar(0)); { if(!a->size) SIMPLE_BAD_ARG_ERROR("random", 1, "array with elements in it"); push_svalue(a->item + (my_rand() % a->size)); stack_swap();