ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/common/urand.c
(Generate patch)

Comparing ray/src/common/urand.c (file contents):
Revision 2.11 by greg, Wed May 27 08:42:06 2015 UTC vs.
Revision 2.13 by greg, Thu Apr 21 02:55:19 2022 UTC

# Line 7 | Line 7 | static const char      RCSid[] = "$Id$";
7  
8   #include "copyright.h"
9  
10 < #include  "standard.h"
10 > #include  "rterror.h"
11   #include  "random.h"
12  
13   #undef initurand
# Line 19 | Line 19 | static unsigned short  empty_tab = 0;
19   unsigned short  *urperm = &empty_tab;   /* urand() permutation */
20   int  urmask = 0;                        /* bits used in permutation */
21  
22 +
23 + long
24 + irandom(                        /* better than using random() % modulus */
25 +        long modulus
26 + )
27 + {
28 +        if ((sizeof(long) == 8) | (sizeof(int) == 8))
29 +                return((random()*modulus)>>31);
30 +
31 +        if (sizeof(long long) == 8)
32 +                return((random()*(long long)modulus)>>31);
33 +
34 +        return(random() % modulus);
35 + }
36  
37   int
38   initurand(                      /* initialize urand() for size entries */

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines