aboutsummaryrefslogtreecommitdiff
path: root/lib/std/fmt.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2022-04-12 06:37:12 -0400
committerGitHub <noreply@github.com>2022-04-12 06:37:12 -0400
commit17631cb2d30bf2d7b10401cf8f784a599bade5c5 (patch)
tree8ba131f77ef38c531711c7b1147c59e993cab628 /lib/std/fmt.zig
parent17daba1806896a2e45a2c1b1969a540f44a64d86 (diff)
parent9b5c02022f997d01bcfcfd79ba4c721af1bd9a6c (diff)
downloadzig-17631cb2d30bf2d7b10401cf8f784a599bade5c5.tar.gz
zig-17631cb2d30bf2d7b10401cf8f784a599bade5c5.zip
Merge pull request #11401 from viriuwu/float-category-misc
math: simplify inf (+f80 support), deprecate old constants (followup for #10133)
Diffstat (limited to 'lib/std/fmt.zig')
-rw-r--r--lib/std/fmt.zig32
1 files changed, 16 insertions, 16 deletions
diff --git a/lib/std/fmt.zig b/lib/std/fmt.zig
index 6d4f3a1daa..03395c024c 100644
--- a/lib/std/fmt.zig
+++ b/lib/std/fmt.zig
@@ -2228,8 +2228,8 @@ test "float.special" {
if (builtin.target.cpu.arch != .arm) {
try expectFmt("f64: -nan", "f64: {}", .{-math.nan_f64});
}
- try expectFmt("f64: inf", "f64: {}", .{math.inf_f64});
- try expectFmt("f64: -inf", "f64: {}", .{-math.inf_f64});
+ try expectFmt("f64: inf", "f64: {}", .{math.inf(f64)});
+ try expectFmt("f64: -inf", "f64: {}", .{-math.inf(f64)});
}
test "float.hexadecimal.special" {
@@ -2239,8 +2239,8 @@ test "float.hexadecimal.special" {
if (builtin.target.cpu.arch != .arm) {
try expectFmt("f64: -nan", "f64: {x}", .{-math.nan_f64});
}
- try expectFmt("f64: inf", "f64: {x}", .{math.inf_f64});
- try expectFmt("f64: -inf", "f64: {x}", .{-math.inf_f64});
+ try expectFmt("f64: inf", "f64: {x}", .{math.inf(f64)});
+ try expectFmt("f64: -inf", "f64: {x}", .{-math.inf(f64)});
try expectFmt("f64: 0x0.0p0", "f64: {x}", .{@as(f64, 0)});
try expectFmt("f64: -0x0.0p0", "f64: {x}", .{-@as(f64, 0)});
@@ -2252,20 +2252,20 @@ test "float.hexadecimal" {
try expectFmt("f64: 0x1.5555555555555p-2", "f64: {x}", .{@as(f64, 1.0 / 3.0)});
try expectFmt("f128: 0x1.5555555555555555555555555555p-2", "f128: {x}", .{@as(f128, 1.0 / 3.0)});
- try expectFmt("f16: 0x1p-14", "f16: {x}", .{@as(f16, math.f16_min)});
- try expectFmt("f32: 0x1p-126", "f32: {x}", .{@as(f32, math.f32_min)});
- try expectFmt("f64: 0x1p-1022", "f64: {x}", .{@as(f64, math.f64_min)});
- try expectFmt("f128: 0x1p-16382", "f128: {x}", .{@as(f128, math.f128_min)});
+ try expectFmt("f16: 0x1p-14", "f16: {x}", .{math.floatMin(f16)});
+ try expectFmt("f32: 0x1p-126", "f32: {x}", .{math.floatMin(f32)});
+ try expectFmt("f64: 0x1p-1022", "f64: {x}", .{math.floatMin(f64)});
+ try expectFmt("f128: 0x1p-16382", "f128: {x}", .{math.floatMin(f128)});
- try expectFmt("f16: 0x0.004p-14", "f16: {x}", .{@as(f16, math.f16_true_min)});
- try expectFmt("f32: 0x0.000002p-126", "f32: {x}", .{@as(f32, math.f32_true_min)});
- try expectFmt("f64: 0x0.0000000000001p-1022", "f64: {x}", .{@as(f64, math.f64_true_min)});
- try expectFmt("f128: 0x0.0000000000000000000000000001p-16382", "f128: {x}", .{@as(f128, math.f128_true_min)});
+ try expectFmt("f16: 0x0.004p-14", "f16: {x}", .{math.floatTrueMin(f16)});
+ try expectFmt("f32: 0x0.000002p-126", "f32: {x}", .{math.floatTrueMin(f32)});
+ try expectFmt("f64: 0x0.0000000000001p-1022", "f64: {x}", .{math.floatTrueMin(f64)});
+ try expectFmt("f128: 0x0.0000000000000000000000000001p-16382", "f128: {x}", .{math.floatTrueMin(f128)});
- try expectFmt("f16: 0x1.ffcp15", "f16: {x}", .{@as(f16, math.f16_max)});
- try expectFmt("f32: 0x1.fffffep127", "f32: {x}", .{@as(f32, math.f32_max)});
- try expectFmt("f64: 0x1.fffffffffffffp1023", "f64: {x}", .{@as(f64, math.f64_max)});
- try expectFmt("f128: 0x1.ffffffffffffffffffffffffffffp16383", "f128: {x}", .{@as(f128, math.f128_max)});
+ try expectFmt("f16: 0x1.ffcp15", "f16: {x}", .{math.floatMax(f16)});
+ try expectFmt("f32: 0x1.fffffep127", "f32: {x}", .{math.floatMax(f32)});
+ try expectFmt("f64: 0x1.fffffffffffffp1023", "f64: {x}", .{math.floatMax(f64)});
+ try expectFmt("f128: 0x1.ffffffffffffffffffffffffffffp16383", "f128: {x}", .{math.floatMax(f128)});
}
test "float.hexadecimal.precision" {