Random

Overview

Represents a pseudo-random number generator.

The values produced by the Random class equals to those produced by the java.util.Random.

Location

  • Reference: Sugar
  • Namespace: Sugar

Instance Methods


constructor

Creates a new instance of the class which uses current time as a random seed.

 

constructor

 

Random()

 

init()

 

Random()

 

Sub New()

constructor (UInt64)

Creates a new instance of the class with specified random seed.

 

constructor(aSeed: UInt64)

 

Random(UInt64 aSeed)

 

init(_ aSeed: UInt64)

 

Random(UInt64 aSeed)

 

Sub New(aSeed As UInt64)

Parameters:

  • aSeed: A number used to calculate a starting value for the pseudo-random number sequence. Providing an identical seed value to different Random objects causes each instance to produce identical sequences of random numbers.

NextDouble

Returns random uniformly distributed double value between 0.0 and 1.0.

 

method NextDouble: Double

 

Double NextDouble()

 

func NextDouble() -> Double

 

Double NextDouble()

 

Function NextDouble() As Double

NextInt

Returns a nonnegative random integer.

 

method NextInt: Int32

 

Int32 NextInt()

 

func NextInt() -> Int32

 

Int32 NextInt()

 

Function NextInt() As Int32

NextInt (Int32): Int32

Returns a nonnegative random integer that is less than the specified maximum.

 

method NextInt(MaxValuePlusOne: Int32): Int32

 

Int32 NextInt(Int32 MaxValuePlusOne)

 

func NextInt(_ MaxValuePlusOne: Int32) -> Int32

 

Int32 NextInt(Int32 MaxValuePlusOne)

 

Function NextInt(MaxValuePlusOne As Int32) As Int32

Parameters:

  • MaxValuePlusOne: The exclusive upper bound of the random number to be generated.