Package io.jawk.jrt

Class BSDRandom

java.lang.Object
io.jawk.jrt.BSDRandom

public class BSDRandom extends Object
Simple pseudo-random number generator compatible with the C library random() function.
  • Constructor Details

    • BSDRandom

      public BSDRandom(int seed)
      Creates a new generator with the specified seed.
      Parameters:
      seed - Initial pseudo-random seed
  • Method Details

    • setSeed

      public final void setSeed(int newSeed)
      Seed the generator. A seed of 0 is transformed to 1 as in the original implementation.
      Parameters:
      newSeed - New pseudo-random seed
    • getSeed

      public int getSeed()
      Returns the seed most recently supplied to setSeed(int).
      Returns:
      Current pseudo-random seed
    • nextDouble

      public double nextDouble()
      Return the next pseudo-random number in the range [0.0,1.0).
      Returns:
      Next pseudo-random floating-point value