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.

floatExp

Return an exponentially distributed float with a rate parameter of 1.

To use a different rate parameter, use: floatExp(...) / desiredRate.

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

File

lib/std/Random.zig:355

Code

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