std.math.scalbn.expect
别名
别名目标 std.testing.expect
std.math.scalbn.scalbn
别名
返回 a * FLT_RADIX ^ exp。
Zig 仅支持二进制 IEEE-754 浮点数,因此 FLT_RADIX=2,此函数是 ldexp 的别名。
别名目标 std.math.ldexp.ldexp
std.math.scalbn.std
别名
别名目标 std
源码
std/math/scalbn.zig
const std = @import("std");
const expect = std.testing.expect;
/// 返回 a * FLT_RADIX ^ exp。
///
/// Zig 仅支持二进制 IEEE-754 浮点数,因此 FLT_RADIX=2,此函数是 ldexp 的别名。
pub const scalbn = @import("ldexp.zig").ldexp;
test scalbn {
// 验证所用的基数为 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);
}