aboutsummaryrefslogtreecommitdiff
path: root/lib/std/math/scalbn.zig
blob: 294ee4abf068090d0c477d86ef5f8c9aa1ef6c9e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
const std = @import("std");
const expect = std.testing.expect;

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

test "math.scalbn" {
    // Verify we are using radix 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);
}