pub struct UniformFloat<X> { /* private fields */ }
Expand description

The back-end implementing UniformSampler for floating-point types.

Unless you are implementing UniformSampler for your own type, this type should not be used directly, use Uniform instead.

Implementation notes

Instead of generating a float in the [0, 1) range using Standard, the UniformFloat implementation converts the output of an PRNG itself. This way one or two steps can be optimized out.

The floats are first converted to a value in the [1, 2) interval using a transmute-based method, and then mapped to the expected range with a multiply and addition. Values produced this way have what equals 23 bits of random digits for an f32, and 52 for an f64.

Trait Implementations§

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
The type sampled by this implementation.
Construct self, with inclusive lower bound and exclusive upper bound [low, high). Read more
Construct self, with inclusive bounds [low, high]. Read more
Sample a value.
Sample a single value uniformly from a range with inclusive lower bound and exclusive upper bound [low, high). Read more
Sample a single value uniformly from a range with inclusive lower bound and inclusive upper bound [low, high]. Read more
The type sampled by this implementation.
Construct self, with inclusive lower bound and exclusive upper bound [low, high). Read more
Construct self, with inclusive bounds [low, high]. Read more
Sample a value.
Sample a single value uniformly from a range with inclusive lower bound and exclusive upper bound [low, high). Read more
Sample a single value uniformly from a range with inclusive lower bound and inclusive upper bound [low, high]. Read more

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.