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 Summary

    Constructors
    Constructor
    Description
    BSDRandom(int seed)
    Creates a new generator with the specified seed.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
    Return the next pseudo-random number in the range [0.0,1.0).
    final void
    setSeed(int seed)
    Seed the generator.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 seed)
      Seed the generator. A seed of 0 is transformed to 1 as in the original implementation.
      Parameters:
      seed - New 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