Skip to content
Standard libraryZig 0.17.0Official documentation
Sourcestd/math/scalbn.zig

Source line 1

std.math.scalbn.expect

alias

Source line 2

Alias of std.testing.expect

std.math.scalbn.scalbn

alias

Source line 7

Returns a * FLT_RADIX ^ exp.

Zig only supports binary base IEEE-754 floats. Hence FLT_RADIX=2, and this is an alias for ldexp.

Alias of std.math.ldexp.ldexp

std.math.scalbn.std

alias

Source line 1

Alias of std

Source code

std/math/scalbn.zig

const std = @import("std");
const expect = std.testing.expect;

/// Returns a * FLT_RADIX ^ exp.
///
/// Zig only supports binary base IEEE-754 floats. Hence FLT_RADIX=2, and this is an alias for ldexp.
pub const scalbn = @import("ldexp.zig").ldexp;

test scalbn {
    // Verify we are using base 2.
    try expect(scalbn(@as(f16, 1.5), 4) == 24.0);
    try expect(scalbn(@as(f32, 1.5), 4) == 24.0);
    try expect(scalbn(@as(f64, 1.5), 4) == 24.0);
    try expect(scalbn(@as(f128, 1.5), 4) == 24.0);
}