Randomizer

org.scalatest.prop.Randomizer
See theRandomizer companion object
class Randomizer(val seed: Long)

Provide random values, of many different types.

This is loosely inspired by java.util.Random (and is designed to produce the same values in conventional cases), with two major differences:

  • It provides random values for many more types;
  • In proper Scala fashion, this class is immutable.

On the first of those points, this returns many data types, including many of the tightly-defined numeric types from Scalactic. These allow you to put tight constraints on precisely what numbers you want to have available -- positive, negative, zeroes, infinities and so on. We strongly recommend that you use the function that most exactly describes the values you are looking for.

That second point is the more important one. You shouldn't call the same Randomizer over and over, the way you would do in Java. Instead, each call to a Randomizer function returns the ''next'' Randomizer, which you should use for the next call.

'''If you are using random floating-point values:''' the algorithms in use here produce random values across the potential space of values. But due to the way floating-point works, this means that these values are strongly biased towards ''small'' numbers. There are many floating-point numbers with negative exponents, so you may get more numbers in the range between -1 and 1 than you expect.

Attributes

Companion
object
Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def chooseByte(from: Byte, to: Byte): (Byte, Randomizer)

Given a range of Bytes, chooses one of them randomly.

Given a range of Bytes, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseChar(from: Char, to: Char): (Char, Randomizer)

Given a range of Chars, chooses one of them randomly.

Given a range of Chars, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseDouble(from: Double, to: Double): (Double, Randomizer)

Given a range of Doubles, chooses one of them randomly.

Given a range of Doubles, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseFiniteDouble(from: FiniteDouble, to: FiniteDouble): (FiniteDouble, Randomizer)

Given a range of finite Doubles, chooses one of them randomly.

Given a range of finite Doubles, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseFiniteFloat(from: FiniteFloat, to: FiniteFloat): (FiniteFloat, Randomizer)

Given a range of finite Floats, chooses one of them randomly.

Given a range of finite Floats, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseFloat(from: Float, to: Float): (Float, Randomizer)

Given a range of Floats, chooses one of them randomly.

Given a range of Floats, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseInt(from: Int, to: Int): (Int, Randomizer)

Given a range of Ints, chooses one of them randomly.

Given a range of Ints, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseLong(from: Long, to: Long): (Long, Randomizer)

Given a range of Longs, chooses one of them randomly.

Given a range of Longs, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNegDouble(from: NegDouble, to: NegDouble): (NegDouble, Randomizer)

Given a range of negative Doubles, chooses one of them randomly.

Given a range of negative Doubles, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNegFiniteDouble(from: NegFiniteDouble, to: NegFiniteDouble): (NegFiniteDouble, Randomizer)

Given a range of negative, finite Doubles, chooses one of them randomly.

Given a range of negative, finite Doubles, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNegFiniteFloat(from: NegFiniteFloat, to: NegFiniteFloat): (NegFiniteFloat, Randomizer)

Given a range of negative, finite Floats, chooses one of them randomly.

Given a range of negative, finite Floats, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNegFloat(from: NegFloat, to: NegFloat): (NegFloat, Randomizer)

Given a range of negative Floats, chooses one of them randomly.

Given a range of negative Floats, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNegInt(from: NegInt, to: NegInt): (NegInt, Randomizer)

Given a range of negative Ints, chooses one of them randomly.

Given a range of negative Ints, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNegLong(from: NegLong, to: NegLong): (NegLong, Randomizer)

Given a range of negative Longs, chooses one of them randomly.

Given a range of negative Longs, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNegZDouble(from: NegZDouble, to: NegZDouble): (NegZDouble, Randomizer)

Given a range of negative Doubles (maybe including zero), chooses one of them randomly.

Given a range of negative Doubles (maybe including zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNegZFiniteDouble(from: NegZFiniteDouble, to: NegZFiniteDouble): (NegZFiniteDouble, Randomizer)

Given a range of negative, finite Doubles (maybe including zero), chooses one of them randomly.

Given a range of negative, finite Doubles (maybe including zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNegZFiniteFloat(from: NegZFiniteFloat, to: NegZFiniteFloat): (NegZFiniteFloat, Randomizer)

Given a range of negative, finite Floats (maybe including zero), chooses one of them randomly.

Given a range of negative, finite Floats (maybe including zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNegZFloat(from: NegZFloat, to: NegZFloat): (NegZFloat, Randomizer)

Given a range of negative Floats (maybe including zero), chooses one of them randomly.

Given a range of negative Floats (maybe including zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNegZInt(from: NegZInt, to: NegZInt): (NegZInt, Randomizer)

Given a range of negative Ints (maybe including zero), chooses one of them randomly.

Given a range of negative Ints (maybe including zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNegZLong(from: NegZLong, to: NegZLong): (NegZLong, Randomizer)

Given a range of negative Longs (maybe including zero), chooses one of them randomly.

Given a range of negative Longs (maybe including zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNonZeroDouble(from: NonZeroDouble, to: NonZeroDouble): (NonZeroDouble, Randomizer)

Given a range of Doubles (excluding zero), chooses one of them randomly.

Given a range of Doubles (excluding zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

In order to avoid returning 0, this function is very slightly biased towards returning 1 instead.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNonZeroFiniteDouble(from: NonZeroFiniteDouble, to: NonZeroFiniteDouble): (NonZeroFiniteDouble, Randomizer)

Given a range of finite Doubles (excluding zero), chooses one of them randomly.

Given a range of finite Doubles (excluding zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

In order to avoid returning 0, this function is very slightly biased towards returning 1 instead.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNonZeroFiniteFloat(from: NonZeroFiniteFloat, to: NonZeroFiniteFloat): (NonZeroFiniteFloat, Randomizer)

Given a range of finite Floats (excluding zero), chooses one of them randomly.

Given a range of finite Floats (excluding zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

In order to avoid returning 0, this function is very slightly biased towards returning 1 instead.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNonZeroFloat(from: NonZeroFloat, to: NonZeroFloat): (NonZeroFloat, Randomizer)

Given a range of Floats (excluding zero), chooses one of them randomly.

Given a range of Floats (excluding zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

In order to avoid returning 0, this function is very slightly biased towards returning 1 instead.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNonZeroInt(from: NonZeroInt, to: NonZeroInt): (NonZeroInt, Randomizer)

Given a range of Ints (excluding zero), chooses one of them randomly.

Given a range of Ints (excluding zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

In order to avoid returning 0, this function is very slightly biased towards returning 1 instead.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseNonZeroLong(from: NonZeroLong, to: NonZeroLong): (NonZeroLong, Randomizer)

Given a range of Longs (excluding zero), chooses one of them randomly.

Given a range of Longs (excluding zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

In order to avoid returning 0, this function is very slightly biased towards returning 1 instead.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def choosePosDouble(from: PosDouble, to: PosDouble): (PosDouble, Randomizer)

Given a range of positive Doubles, chooses one of them randomly.

Given a range of positive Doubles, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def choosePosFiniteDouble(from: PosFiniteDouble, to: PosFiniteDouble): (PosFiniteDouble, Randomizer)

Given a range of positive finite Doubles, chooses one of them randomly.

Given a range of positive finite Doubles, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def choosePosFiniteFloat(from: PosFiniteFloat, to: PosFiniteFloat): (PosFiniteFloat, Randomizer)

Given a range of positive, finite Floats, chooses one of them randomly.

Given a range of positive, finite Floats, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def choosePosFloat(from: PosFloat, to: PosFloat): (PosFloat, Randomizer)

Given a range of positive Floats, chooses one of them randomly.

Given a range of positive Floats, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def choosePosInt(from: PosInt, to: PosInt): (PosInt, Randomizer)

Given a range of positive Ints, chooses one of them randomly.

Given a range of positive Ints, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def choosePosLong(from: PosLong, to: PosLong): (PosLong, Randomizer)

Given a range of positive Longs, chooses one of them randomly.

Given a range of positive Longs, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def choosePosZDouble(from: PosZDouble, to: PosZDouble): (PosZDouble, Randomizer)

Given a range of positive Doubles (maybe including zero), chooses one of them randomly.

Given a range of positive Doubles (maybe including zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def choosePosZFiniteDouble(from: PosZFiniteDouble, to: PosZFiniteDouble): (PosZFiniteDouble, Randomizer)

Given a range of positive, finite Doubles (maybe including zero), chooses one of them randomly.

Given a range of positive, finite Doubles (maybe including zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def choosePosZFiniteFloat(from: PosZFiniteFloat, to: PosZFiniteFloat): (PosZFiniteFloat, Randomizer)

Given a range of positive, finite Floats (maybe including zero), chooses one of them randomly.

Given a range of positive, finite Floats (maybe including zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def choosePosZFloat(from: PosZFloat, to: PosZFloat): (PosZFloat, Randomizer)

Given a range of positive Floats (maybe including zero), chooses one of them randomly.

Given a range of positive Floats (maybe including zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def choosePosZInt(from: PosZInt, to: PosZInt): (PosZInt, Randomizer)

Given a range of positive Ints (maybe including zero), chooses one of them randomly.

Given a range of positive Ints (maybe including zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def choosePosZLong(from: PosZLong, to: PosZLong): (PosZLong, Randomizer)

Given a range of positive Longs (maybe including zero), chooses one of them randomly.

Given a range of positive Longs (maybe including zero), chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def chooseShort(from: Short, to: Short): (Short, Randomizer)

Given a range of Shorts, chooses one of them randomly.

Given a range of Shorts, chooses one of them randomly.

Note that, while the ''from'' parameter is usually smaller than ''to'', that is not required; the function will cope appropriately if they are in reverse order.

The choice is inclusive: either the ''from'' or ''to'' values may be returned.

Value parameters

from

One end of the range to select from.

to

The other end of the range.

Attributes

Returns

A value from that range, inclusive of the ends.

def finiteFloatBetweenAlgorithm(between0And1: Float, min: Float, max: Float): Float

Given the endpoints of a finite-Float range, and a scaling factor, this computes the number that far across the range.

Given the endpoints of a finite-Float range, and a scaling factor, this computes the number that far across the range.

This deals with edge cases that can result in infinities in the math.

Value parameters

between0And1

A scaling factor between 0 and 1.

max

The upper end of the range.

min

The lower end of the range.

Attributes

Returns

The Float that is the scaling factor distance across that range.

def next(bits: Int): (Int, Randomizer)

Get a certain number of random bits.

Get a certain number of random bits.

You don't usually call this directly. Instead, call more-specific functions such as nextInt, which calls this for the correct number of bits and then casts that to the desired type.

Value parameters

bits

The number of random bits you need.

Attributes

Returns

The random bits, and the next Randomizer to user.

def nextBit: (Int, Randomizer)

Get a 1 or a 0.

Get a 1 or a 0.

Attributes

Returns

a 1 or 0 as an Int.

def nextByte: (Byte, Randomizer)

Get a random 8-bit Byte.

Get a random 8-bit Byte.

Attributes

Returns

A random Byte, and the next Randomizer to use.

def nextChar: (Char, Randomizer)

Get a random 16-bit Char.

Get a random 16-bit Char.

Note: this intentionally avoids invalid Unicode chars between 0xD800 and 0xDFFF; when one of those is generated, this instead returns a Char between 0x0000 and 0x00FF. So this function slightly favors that first code block. (Which is the most common one in practice, anyway.)

Attributes

Returns

A random Char, and the next Randomizer to use.

def nextDouble: (Double, Randomizer)

Get a random Double.

Get a random Double.

This will randomize the sign, exponent and mantissa, so it can return any possible Double.

Attributes

Returns

A random Double, and the next Randomizer to use.

Get a random Double between 0 and 1.

Get a random Double between 0 and 1.

When working with Double, you often want a value between 0 and 1 -- this sort of proportion is a common use case for Double. This function makes it easy to grab one.

Attributes

Returns

A random Double in that range, and the next Randomizer to use.

def nextFiniteDouble: (FiniteDouble, Randomizer)

Get a random non-infinite Double.

Get a random non-infinite Double.

This can return either a positive or negative value, or zero, but guards against returning either Double.PositiveInfinity, Double.NegativeInfinity, or Double.NaN.

Attributes

Returns

A random finite Double, and the next Randomizer to use.

def nextFiniteFloat: (FiniteFloat, Randomizer)

Get a random non-infinite Float.

Get a random non-infinite Float.

This can return either a positive or negative value, or zero, but guards against returning either Float.PositiveInfinity, Float.NegativeInfinity, or Float.NaN.

Attributes

Returns

A random finite Float, and the next Randomizer to use.

def nextFloat: (Float, Randomizer)

Get a random Float.

Get a random Float.

This will randomize the sign, exponent and mantissa, so it can return any possible Float.

Attributes

Returns

A random Float, and the next Randomizer to use.

Get a random Float between 0 and 1.

Get a random Float between 0 and 1.

When working with Floats, you often want a value between 0 and 1 -- this sort of proportion is one of the more common use cases for Floats. This function makes it easy to grab one.

Attributes

Returns

A random Float in that range, and the next Randomizer to use.

def nextInt: (Int, Randomizer)

Get a random 32-bit Int.

Get a random 32-bit Int.

Attributes

Returns

A random Int, and the next Randomizer to use.

def nextList[T](length: PosZInt)(implicit genOfT: Generator[T]): (List[T], Randomizer)

Get a random list of elements of type T.

Get a random list of elements of type T.

This function requires an implicit parameter that says how to generate values of T, as well as the number of them to generate. (Which may be zero.)

Type parameters

T

The type to generate.

Value parameters

genOfT

A Generator, that provides values of type T.

length

How many values to generate for the List.

Attributes

Returns

A List of values of the desired type.

def nextLong: (Long, Randomizer)

Get a random 64-bit Long.

Get a random 64-bit Long.

Attributes

Returns

A random Long, and the next Randomizer to use.

def nextNegDouble: (NegDouble, Randomizer)

Get a random Double less than zero.

Get a random Double less than zero.

Note: it is possible (although rare) for this to return Double.NegativeInfinity. If you want to avoid that, use nextNegFiniteDouble instead.

Attributes

Returns

A random negative Double, and the next Randomizer to use.

def nextNegFiniteDouble: (NegFiniteDouble, Randomizer)

Get a random Double less than zero.

Get a random Double less than zero.

This guards against returning Double.NegativeInfinity, so you can have confidence that the returned number is real and finite.

Attributes

Returns

A random negative Double, and the next Randomizer to use.

def nextNegFiniteFloat: (NegFiniteFloat, Randomizer)

Get a random Float less than zero.

Get a random Float less than zero.

This guards against returning Float.NegativeInfinity, so you can have confidence that the returned number is real and finite.

Attributes

Returns

A random negative Float, and the next Randomizer to use.

def nextNegFloat: (NegFloat, Randomizer)

Get a random Float less than zero.

Get a random Float less than zero.

Note: it is possible (although rare) for this to return Float.NegativeInfinity. If you want to avoid that, use nextNegFiniteFloat instead.

Attributes

Returns

A random negative Float, and the next Randomizer to use.

def nextNegInt: (NegInt, Randomizer)

Get a random Int less than zero.

Get a random Int less than zero.

Attributes

Returns

A random negative Int, and the next Randomizer to use.

def nextNegLong: (NegLong, Randomizer)

Get a random Long less than zero.

Get a random Long less than zero.

Attributes

Returns

A random negative Long, and the next Randomizer to use.

def nextNegZDouble: (NegZDouble, Randomizer)

Get a random Double less than or equal to zero.

Get a random Double less than or equal to zero.

Note: it is possible (although rare) for this to return Double.NegativeInfinity. If you want to avoid that, use nextNegZFiniteDouble instead.

Attributes

Returns

A random negative-or-zero Double, and the next Randomizer to use.

def nextNegZFiniteDouble: (NegZFiniteDouble, Randomizer)

Get a random Double less than or equal to zero.

Get a random Double less than or equal to zero.

This guards against Double.NegativeInfinity, so it will always return a non-infinite value.

Attributes

Returns

A random negative-or-zero Double, and the next Randomizer to use.

def nextNegZFiniteFloat: (NegZFiniteFloat, Randomizer)

Get a random Float less than or equal to zero.

Get a random Float less than or equal to zero.

This guards against Float.NegativeInfinity, so it will always return a non-infinite value.

Attributes

Returns

A random negative-or-zero Float, and the next Randomizer to use.

def nextNegZFloat: (NegZFloat, Randomizer)

Get a random Float less than or equal to zero.

Get a random Float less than or equal to zero.

Note: it is possible (although rare) for this to return Float.NegativeInfinity. If you want to avoid that, use nextNegZFiniteFloat instead.

Attributes

Returns

A random negative-or-zero Float, and the next Randomizer to use.

def nextNegZInt: (NegZInt, Randomizer)

Get a random Int less than or equal to zero.

Get a random Int less than or equal to zero.

Attributes

Returns

A random negative-or-zero Int, and the next Randomizer to use.

def nextNegZLong: (NegZLong, Randomizer)

Get a random Long less than or equal to zero.

Get a random Long less than or equal to zero.

Attributes

Returns

A random negative-or-zero Long, and the next Randomizer to use.

def nextNonZeroDouble: (NonZeroDouble, Randomizer)

Get a random non-zero Double.

Get a random non-zero Double.

This can return any Double ''except'' zero.

Note that this can return infinite values; if you want to avoid that, use nextNonZeroFiniteDouble instead.

Attributes

Returns

A random non-zero Double, and the next Randomizer to use.

def nextNonZeroFiniteDouble: (NonZeroFiniteDouble, Randomizer)

Get a random non-zero Double.

Get a random non-zero Double.

This can return any Double ''except'' zero, Double.PositiveInfinity, or Double.NegativeInfinity.

Attributes

Returns

A random non-zero Double, and the next Randomizer to use.

def nextNonZeroFiniteFloat: (NonZeroFiniteFloat, Randomizer)

Get a random non-zero Float.

Get a random non-zero Float.

This can return any Float ''except'' zero, Float.PositiveInfinity, or Float.NegativeInfinity.

Attributes

Returns

A random non-zero Float, and the next Randomizer to use.

def nextNonZeroFloat: (NonZeroFloat, Randomizer)

Get a random non-zero Float.

Get a random non-zero Float.

This can return any Float ''except'' zero.

Note that this can return infinite values; if you want to avoid that, use nextNonZeroFiniteFloat instead.

Attributes

Returns

A random non-zero Float, and the next Randomizer to use.

def nextNonZeroInt: (NonZeroInt, Randomizer)

Get a random non-zero Int.

Get a random non-zero Int.

This can return any Int ''except'' zero.

Attributes

Returns

A random non-zero Int, and the next Randomizer to use.

def nextNonZeroLong: (NonZeroLong, Randomizer)

Get a random non-zero Long.

Get a random non-zero Long.

This can return any Long ''except'' zero.

Attributes

Returns

A random non-zero Long, and the next Randomizer to use.

def nextPosDouble: (PosDouble, Randomizer)

Get a random Double greater than zero.

Get a random Double greater than zero.

Note: it is possible (although rare) for this to return Double.PositiveInfinity. If you want to avoid that, use nextPosFiniteDouble instead.

Attributes

Returns

A random positive Double, and the next Randomizer to use.

def nextPosFiniteDouble: (PosFiniteDouble, Randomizer)

Get a random Double greater than zero.

Get a random Double greater than zero.

This guards against returning Double.PositiveInfinity, so you can have confidence that the returned number is real and finite.

Attributes

Returns

A random positive Double, and the next Randomizer to use.

def nextPosFiniteFloat: (PosFiniteFloat, Randomizer)

Get a random, finite Float greater than zero.

Get a random, finite Float greater than zero.

This methods guards against returning Float.PositiveInfinity -- you will always receive a real value.

Attributes

Returns

A random positive Float, and the next Randomizer to use.

def nextPosFloat: (PosFloat, Randomizer)

Get a random Float greater than zero.

Get a random Float greater than zero.

Note: it is possible (although rare) for this to return Float.PositiveInfinity. If you want to avoid that, use nextPosFiniteFloat instead.

Attributes

Returns

A random positive Float, and the next Randomizer to use.

def nextPosInt: (PosInt, Randomizer)

Get a random Integer greater than zero.

Get a random Integer greater than zero.

Note: if the underlying algorithm tries to generate 0, this generates 1, so it is very slightly biased towards returning 1.

Attributes

Returns

A random positive Integer, and the next Randomizer to use.

def nextPosLong: (PosLong, Randomizer)

Get a random Long greater than zero.

Get a random Long greater than zero.

Attributes

Returns

A random positive Long, and the next Randomizer to use.

def nextPosZDouble: (PosZDouble, Randomizer)

Get a random Double greater than or equal to zero.

Get a random Double greater than or equal to zero.

Note: it is possible (although rare) for this to return Double.NegativeInfinity. If you want to avoid that, use nextPosZFiniteDouble instead.

Attributes

Returns

A random positive Double, and the next Randomizer to use.

def nextPosZFiniteDouble: (PosZFiniteDouble, Randomizer)

Get a random Double greater than or equal to zero.

Get a random Double greater than or equal to zero.

This guards against returning Double.NegativeInfinity.

Attributes

Returns

A random negative Double, and the next Randomizer to use.

def nextPosZFiniteFloat: (PosZFiniteFloat, Randomizer)

Get a random Float greater than or equal to zero.

Get a random Float greater than or equal to zero.

This guards against returning Float.PositiveInfinity.

Attributes

Returns

A random positive Float, and the next Randomizer to use.

def nextPosZFloat: (PosZFloat, Randomizer)

Get a random Float greater than or equal to zero.

Get a random Float greater than or equal to zero.

Note: it is possible (although rare) for this to return Float.PositiveInfinity. If you want to avoid that, use nextPosZFiniteFloat instead.

Attributes

Returns

A random positive Float, and the next Randomizer to use.

def nextPosZInt: (PosZInt, Randomizer)

Get a random Integer greater than or equal to zero.

Get a random Integer greater than or equal to zero.

Attributes

Returns

A random positive Integer (or zero), and the next Randomizer to use.

def nextPosZLong: (PosZLong, Randomizer)

Get a random Long greater than or equal to zero.

Get a random Long greater than or equal to zero.

Attributes

Returns

A random positive Long (or zero), and the next Randomizer to use.

Computes the next Randomizer to use.

Computes the next Randomizer to use.

Since Randomizer is immutable (and would thus return the same value over and over), you don't usually use the same instance more than once. Instead, you should fetch the next one, and use that for the next operation.

You usually don't need to call this directly; instead, the next Randomizer is returned from each operation, along with the random value.

Attributes

Returns

The next Randomizer, ready to use.

def nextShort: (Short, Randomizer)

Get a random 16-bit Short.

Get a random 16-bit Short.

Attributes

Returns

A random Short, and the next Randomizer to use.

def nextString(length: PosZInt): (String, Randomizer)

Get a random String.

Get a random String.

This takes a desired length, and generates a String of that length. Do not expect this String to make any sense -- it is literally just a string of random Unicode characters, and will typically contain little or no conventional ASCII.

Value parameters

length

The number of characters to include in the String.

Attributes

Returns

A highly-random String of the specified length, and the next Randomizer to use.

Concrete fields

val seed: Long