pike.git / src / builtin.cmod

version» Context lines:

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.109 2008/04/22 18:17:55 mast Exp $ + || $Id: builtin.cmod,v 1.110 2010/03/23 12:24:39 grubba Exp $   */      #include "global.h"   #include "interpret.h"   #include "svalue.h"   #include "opcodes.h"   #include "pike_macros.h"   #include "object.h"   #include "program.h"   #include "array.h"
pike.git/src/builtin.cmod:895:    optflags OPT_TRY_OPTIMIZE|OPT_EXTERNAL_DEPEND;   {    apply(o,"_random",0);    stack_swap();    pop_stack();   }      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;   }      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) ));