ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/jsr166/jsr166/src/loops/LoopHelpers.java
(Generate patch)

Comparing jsr166/src/loops/LoopHelpers.java (file contents):
Revision 1.1 by jsr166, Fri Apr 9 20:12:06 2004 UTC vs.
Revision 1.2 by peierls, Thu Dec 30 15:15:43 2004 UTC

# Line 12 | Line 12 | class LoopHelpers {
12      // Some mindless computation to do between synchronizations...
13  
14      /**
15 <     * generates 32 bit pseudo-random numbers.
15 >     * generates 32 bit pseudo-random numbers.
16       * Adapted from http://www.snippets.org
17       */
18 <    public static int compute1(int x) {
18 >    public static int compute1(int x) {
19          int lo = 16807 * (x & 0xFFFF);
20          int hi = 16807 * (x >>> 16);
21          lo += (hi & 0x7FFF) << 16;
# Line 35 | Line 35 | class LoopHelpers {
35       *  Computes a linear congruential random number a random number
36       *  of times.
37       */
38 <    public static int compute2(int x) {
38 >    public static int compute2(int x) {
39          int loops = (x >>> 4) & 7;
40          while (loops-- > 0) {
41              x = (x * 2147483647) % 16807;
# Line 43 | Line 43 | class LoopHelpers {
43          return x;
44      }
45  
46 <    public static int compute3(int x) {
46 >    /**
47 >     * Yet another random number generator
48 >     */
49 >    public static int compute3(int x) {
50          int t = (x % 127773) * 16807 - (x / 127773) * 2836;
51          return (t > 0)? t : t + 0x7fffffff;
52      }
53  
54      /**
55 +     * Yet another random number generator
56 +     */
57 +    public static int compute4(int x) {
58 +        return x * 134775813 + 1;
59 +    }
60 +
61 +    /**
62       * An actually useful random number generator, but unsynchronized.
63       * Basically same as java.util.Random.
64       */
# Line 99 | Line 109 | class LoopHelpers {
109          b.replace(b.length()-num.length(), b.length(), num);
110          return b.toString();
111      }
112 <  
112 >
113   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines