Zig 0.17.0-dev (Split by item)

This is an example of documentation generated by ZigDoc, an alternative to Zig's built-in Auto Doc feature. See also examples in other modes/formats. The project being documented here (as the example) is the Zig library itself.

floatNorm

Return a floating point value normally distributed with mean = 0, stddev = 1.

To use different parameters, use: floatNorm(...) * desiredStddev + desiredMean.

Random.floatNorm
pub fn floatNorm(r: Random, comptime T: type) T

File

lib/std/Random.zig:343

Code

pub fn floatNorm(r: Random, comptime T: type) T {
    const value = ziggurat.next_f64(r, ziggurat.NormDist);
    switch (T) {
        f32 => return @floatCast(value),
        f64 => return value,
        else => @compileError("unknown floating point type"),
    }
}