| author | |
| committer | |
| log | 17631cb2d30bf2d7b10401cf8f784a599bade5c5 |
| tree | 8ba131f77ef38c531711c7b1147c59e993cab628 |
| parent | 17daba1806896a2e45a2c1b1969a540f44a64d86 |
| parent | 9b5c02022f997d01bcfcfd79ba4c721af1bd9a6c |
| signature |
math: simplify inf (+f80 support), deprecate old constants (followup for #10133)31 files changed, 264 insertions(+), 353 deletions(-)
CMakeLists.txt+1-1| ... | @@ -444,9 +444,9 @@ set(ZIG_STAGE2_SOURCES | ... | @@ -444,9 +444,9 @@ set(ZIG_STAGE2_SOURCES |
| 444 | "${CMAKE_SOURCE_DIR}/lib/std/math.zig" | 444 | "${CMAKE_SOURCE_DIR}/lib/std/math.zig" |
| 445 | "${CMAKE_SOURCE_DIR}/lib/std/math/big.zig" | 445 | "${CMAKE_SOURCE_DIR}/lib/std/math/big.zig" |
| 446 | "${CMAKE_SOURCE_DIR}/lib/std/math/big/int.zig" | 446 | "${CMAKE_SOURCE_DIR}/lib/std/math/big/int.zig" |
| 447 | "${CMAKE_SOURCE_DIR}/lib/std/math/float.zig" | ||
| 447 | "${CMAKE_SOURCE_DIR}/lib/std/math/floor.zig" | 448 | "${CMAKE_SOURCE_DIR}/lib/std/math/floor.zig" |
| 448 | "${CMAKE_SOURCE_DIR}/lib/std/math/frexp.zig" | 449 | "${CMAKE_SOURCE_DIR}/lib/std/math/frexp.zig" |
| 449 | "${CMAKE_SOURCE_DIR}/lib/std/math/inf.zig" | ||
| 450 | "${CMAKE_SOURCE_DIR}/lib/std/math/isinf.zig" | 450 | "${CMAKE_SOURCE_DIR}/lib/std/math/isinf.zig" |
| 451 | "${CMAKE_SOURCE_DIR}/lib/std/math/isnan.zig" | 451 | "${CMAKE_SOURCE_DIR}/lib/std/math/isnan.zig" |
| 452 | "${CMAKE_SOURCE_DIR}/lib/std/math/ln.zig" | 452 | "${CMAKE_SOURCE_DIR}/lib/std/math/ln.zig" |
lib/std/fmt.zig+16-16| ... | @@ -2228,8 +2228,8 @@ test "float.special" { | ... | @@ -2228,8 +2228,8 @@ test "float.special" { |
| 2228 | if (builtin.target.cpu.arch != .arm) { | 2228 | if (builtin.target.cpu.arch != .arm) { |
| 2229 | try expectFmt("f64: -nan", "f64: {}", .{-math.nan_f64}); | 2229 | try expectFmt("f64: -nan", "f64: {}", .{-math.nan_f64}); |
| 2230 | } | 2230 | } |
| 2231 | try expectFmt("f64: inf", "f64: {}", .{math.inf_f64}); | 2231 | try expectFmt("f64: inf", "f64: {}", .{math.inf(f64)}); |
| 2232 | try expectFmt("f64: -inf", "f64: {}", .{-math.inf_f64}); | 2232 | try expectFmt("f64: -inf", "f64: {}", .{-math.inf(f64)}); |
| 2233 | } | 2233 | } |
| 2234 | 2234 | ||
| 2235 | test "float.hexadecimal.special" { | 2235 | test "float.hexadecimal.special" { |
| ... | @@ -2239,8 +2239,8 @@ test "float.hexadecimal.special" { | ... | @@ -2239,8 +2239,8 @@ test "float.hexadecimal.special" { |
| 2239 | if (builtin.target.cpu.arch != .arm) { | 2239 | if (builtin.target.cpu.arch != .arm) { |
| 2240 | try expectFmt("f64: -nan", "f64: {x}", .{-math.nan_f64}); | 2240 | try expectFmt("f64: -nan", "f64: {x}", .{-math.nan_f64}); |
| 2241 | } | 2241 | } |
| 2242 | try expectFmt("f64: inf", "f64: {x}", .{math.inf_f64}); | 2242 | try expectFmt("f64: inf", "f64: {x}", .{math.inf(f64)}); |
| 2243 | try expectFmt("f64: -inf", "f64: {x}", .{-math.inf_f64}); | 2243 | try expectFmt("f64: -inf", "f64: {x}", .{-math.inf(f64)}); |
| 2244 | 2244 | ||
| 2245 | try expectFmt("f64: 0x0.0p0", "f64: {x}", .{@as(f64, 0)}); | 2245 | try expectFmt("f64: 0x0.0p0", "f64: {x}", .{@as(f64, 0)}); |
| 2246 | try expectFmt("f64: -0x0.0p0", "f64: {x}", .{-@as(f64, 0)}); | 2246 | try expectFmt("f64: -0x0.0p0", "f64: {x}", .{-@as(f64, 0)}); |
| ... | @@ -2252,20 +2252,20 @@ test "float.hexadecimal" { | ... | @@ -2252,20 +2252,20 @@ test "float.hexadecimal" { |
| 2252 | try expectFmt("f64: 0x1.5555555555555p-2", "f64: {x}", .{@as(f64, 1.0 / 3.0)}); | 2252 | try expectFmt("f64: 0x1.5555555555555p-2", "f64: {x}", .{@as(f64, 1.0 / 3.0)}); |
| 2253 | try expectFmt("f128: 0x1.5555555555555555555555555555p-2", "f128: {x}", .{@as(f128, 1.0 / 3.0)}); | 2253 | try expectFmt("f128: 0x1.5555555555555555555555555555p-2", "f128: {x}", .{@as(f128, 1.0 / 3.0)}); |
| 2254 | 2254 | ||
| 2255 | try expectFmt("f16: 0x1p-14", "f16: {x}", .{@as(f16, math.f16_min)}); | 2255 | try expectFmt("f16: 0x1p-14", "f16: {x}", .{math.floatMin(f16)}); |
| 2256 | try expectFmt("f32: 0x1p-126", "f32: {x}", .{@as(f32, math.f32_min)}); | 2256 | try expectFmt("f32: 0x1p-126", "f32: {x}", .{math.floatMin(f32)}); |
| 2257 | try expectFmt("f64: 0x1p-1022", "f64: {x}", .{@as(f64, math.f64_min)}); | 2257 | try expectFmt("f64: 0x1p-1022", "f64: {x}", .{math.floatMin(f64)}); |
| 2258 | try expectFmt("f128: 0x1p-16382", "f128: {x}", .{@as(f128, math.f128_min)}); | 2258 | try expectFmt("f128: 0x1p-16382", "f128: {x}", .{math.floatMin(f128)}); |
| 2259 | 2259 | ||
| 2260 | try expectFmt("f16: 0x0.004p-14", "f16: {x}", .{@as(f16, math.f16_true_min)}); | 2260 | try expectFmt("f16: 0x0.004p-14", "f16: {x}", .{math.floatTrueMin(f16)}); |
| 2261 | try expectFmt("f32: 0x0.000002p-126", "f32: {x}", .{@as(f32, math.f32_true_min)}); | 2261 | try expectFmt("f32: 0x0.000002p-126", "f32: {x}", .{math.floatTrueMin(f32)}); |
| 2262 | try expectFmt("f64: 0x0.0000000000001p-1022", "f64: {x}", .{@as(f64, math.f64_true_min)}); | 2262 | try expectFmt("f64: 0x0.0000000000001p-1022", "f64: {x}", .{math.floatTrueMin(f64)}); |
| 2263 | try expectFmt("f128: 0x0.0000000000000000000000000001p-16382", "f128: {x}", .{@as(f128, math.f128_true_min)}); | 2263 | try expectFmt("f128: 0x0.0000000000000000000000000001p-16382", "f128: {x}", .{math.floatTrueMin(f128)}); |
| 2264 | 2264 | ||
| 2265 | try expectFmt("f16: 0x1.ffcp15", "f16: {x}", .{@as(f16, math.f16_max)}); | 2265 | try expectFmt("f16: 0x1.ffcp15", "f16: {x}", .{math.floatMax(f16)}); |
| 2266 | try expectFmt("f32: 0x1.fffffep127", "f32: {x}", .{@as(f32, math.f32_max)}); | 2266 | try expectFmt("f32: 0x1.fffffep127", "f32: {x}", .{math.floatMax(f32)}); |
| 2267 | try expectFmt("f64: 0x1.fffffffffffffp1023", "f64: {x}", .{@as(f64, math.f64_max)}); | 2267 | try expectFmt("f64: 0x1.fffffffffffffp1023", "f64: {x}", .{math.floatMax(f64)}); |
| 2268 | try expectFmt("f128: 0x1.ffffffffffffffffffffffffffffp16383", "f128: {x}", .{@as(f128, math.f128_max)}); | 2268 | try expectFmt("f128: 0x1.ffffffffffffffffffffffffffffp16383", "f128: {x}", .{math.floatMax(f128)}); |
| 2269 | } | 2269 | } |
| 2270 | 2270 | ||
| 2271 | test "float.hexadecimal.precision" { | 2271 | test "float.hexadecimal.precision" { |
lib/std/fmt/parse_hex_float.zig+24-24| ... | @@ -262,14 +262,14 @@ test "f16" { | ... | @@ -262,14 +262,14 @@ test "f16" { |
| 262 | .{ .s = "0x10p+10", .v = 16384.0 }, | 262 | .{ .s = "0x10p+10", .v = 16384.0 }, |
| 263 | .{ .s = "0x10p-10", .v = 0.015625 }, | 263 | .{ .s = "0x10p-10", .v = 0.015625 }, |
| 264 | // Max normalized value. | 264 | // Max normalized value. |
| 265 | .{ .s = "0x1.ffcp+15", .v = math.f16_max }, | 265 | .{ .s = "0x1.ffcp+15", .v = math.floatMax(f16) }, |
| 266 | .{ .s = "-0x1.ffcp+15", .v = -math.f16_max }, | 266 | .{ .s = "-0x1.ffcp+15", .v = -math.floatMax(f16) }, |
| 267 | // Min normalized value. | 267 | // Min normalized value. |
| 268 | .{ .s = "0x1p-14", .v = math.f16_min }, | 268 | .{ .s = "0x1p-14", .v = math.floatMin(f16) }, |
| 269 | .{ .s = "-0x1p-14", .v = -math.f16_min }, | 269 | .{ .s = "-0x1p-14", .v = -math.floatMin(f16) }, |
| 270 | // Min denormal value. | 270 | // Min denormal value. |
| 271 | .{ .s = "0x1p-24", .v = math.f16_true_min }, | 271 | .{ .s = "0x1p-24", .v = math.floatTrueMin(f16) }, |
| 272 | .{ .s = "-0x1p-24", .v = -math.f16_true_min }, | 272 | .{ .s = "-0x1p-24", .v = -math.floatTrueMin(f16) }, |
| 273 | }; | 273 | }; |
| 274 | 274 | ||
| 275 | for (cases) |case| { | 275 | for (cases) |case| { |
| ... | @@ -286,14 +286,14 @@ test "f32" { | ... | @@ -286,14 +286,14 @@ test "f32" { |
| 286 | .{ .s = "0x0.ffffffp128", .v = 0x0.ffffffp128 }, | 286 | .{ .s = "0x0.ffffffp128", .v = 0x0.ffffffp128 }, |
| 287 | .{ .s = "0x0.1234570p-125", .v = 0x0.1234570p-125 }, | 287 | .{ .s = "0x0.1234570p-125", .v = 0x0.1234570p-125 }, |
| 288 | // Max normalized value. | 288 | // Max normalized value. |
| 289 | .{ .s = "0x1.fffffeP+127", .v = math.f32_max }, | 289 | .{ .s = "0x1.fffffeP+127", .v = math.floatMax(f32) }, |
| 290 | .{ .s = "-0x1.fffffeP+127", .v = -math.f32_max }, | 290 | .{ .s = "-0x1.fffffeP+127", .v = -math.floatMax(f32) }, |
| 291 | // Min normalized value. | 291 | // Min normalized value. |
| 292 | .{ .s = "0x1p-126", .v = math.f32_min }, | 292 | .{ .s = "0x1p-126", .v = math.floatMin(f32) }, |
| 293 | .{ .s = "-0x1p-126", .v = -math.f32_min }, | 293 | .{ .s = "-0x1p-126", .v = -math.floatMin(f32) }, |
| 294 | // Min denormal value. | 294 | // Min denormal value. |
| 295 | .{ .s = "0x1P-149", .v = math.f32_true_min }, | 295 | .{ .s = "0x1P-149", .v = math.floatTrueMin(f32) }, |
| 296 | .{ .s = "-0x1P-149", .v = -math.f32_true_min }, | 296 | .{ .s = "-0x1P-149", .v = -math.floatTrueMin(f32) }, |
| 297 | }; | 297 | }; |
| 298 | 298 | ||
| 299 | for (cases) |case| { | 299 | for (cases) |case| { |
| ... | @@ -308,14 +308,14 @@ test "f64" { | ... | @@ -308,14 +308,14 @@ test "f64" { |
| 308 | .{ .s = "0x10p+10", .v = 16384.0 }, | 308 | .{ .s = "0x10p+10", .v = 16384.0 }, |
| 309 | .{ .s = "0x10p-10", .v = 0.015625 }, | 309 | .{ .s = "0x10p-10", .v = 0.015625 }, |
| 310 | // Max normalized value. | 310 | // Max normalized value. |
| 311 | .{ .s = "0x1.fffffffffffffp+1023", .v = math.f64_max }, | 311 | .{ .s = "0x1.fffffffffffffp+1023", .v = math.floatMax(f64) }, |
| 312 | .{ .s = "-0x1.fffffffffffffp1023", .v = -math.f64_max }, | 312 | .{ .s = "-0x1.fffffffffffffp1023", .v = -math.floatMax(f64) }, |
| 313 | // Min normalized value. | 313 | // Min normalized value. |
| 314 | .{ .s = "0x1p-1022", .v = math.f64_min }, | 314 | .{ .s = "0x1p-1022", .v = math.floatMin(f64) }, |
| 315 | .{ .s = "-0x1p-1022", .v = -math.f64_min }, | 315 | .{ .s = "-0x1p-1022", .v = -math.floatMin(f64) }, |
| 316 | // Min denormalized value. | 316 | // Min denormalized value. |
| 317 | .{ .s = "0x1p-1074", .v = math.f64_true_min }, | 317 | .{ .s = "0x1p-1074", .v = math.floatTrueMin(f64) }, |
| 318 | .{ .s = "-0x1p-1074", .v = -math.f64_true_min }, | 318 | .{ .s = "-0x1p-1074", .v = -math.floatTrueMin(f64) }, |
| 319 | }; | 319 | }; |
| 320 | 320 | ||
| 321 | for (cases) |case| { | 321 | for (cases) |case| { |
| ... | @@ -330,14 +330,14 @@ test "f128" { | ... | @@ -330,14 +330,14 @@ test "f128" { |
| 330 | .{ .s = "0x10p+10", .v = 16384.0 }, | 330 | .{ .s = "0x10p+10", .v = 16384.0 }, |
| 331 | .{ .s = "0x10p-10", .v = 0.015625 }, | 331 | .{ .s = "0x10p-10", .v = 0.015625 }, |
| 332 | // Max normalized value. | 332 | // Max normalized value. |
| 333 | .{ .s = "0xf.fffffffffffffffffffffffffff8p+16380", .v = math.f128_max }, | 333 | .{ .s = "0xf.fffffffffffffffffffffffffff8p+16380", .v = math.floatMax(f128) }, |
| 334 | .{ .s = "-0xf.fffffffffffffffffffffffffff8p+16380", .v = -math.f128_max }, | 334 | .{ .s = "-0xf.fffffffffffffffffffffffffff8p+16380", .v = -math.floatMax(f128) }, |
| 335 | // Min normalized value. | 335 | // Min normalized value. |
| 336 | .{ .s = "0x1p-16382", .v = math.f128_min }, | 336 | .{ .s = "0x1p-16382", .v = math.floatMin(f128) }, |
| 337 | .{ .s = "-0x1p-16382", .v = -math.f128_min }, | 337 | .{ .s = "-0x1p-16382", .v = -math.floatMin(f128) }, |
| 338 | // // Min denormalized value. | 338 | // // Min denormalized value. |
| 339 | .{ .s = "0x1p-16494", .v = math.f128_true_min }, | 339 | .{ .s = "0x1p-16494", .v = math.floatTrueMin(f128) }, |
| 340 | .{ .s = "-0x1p-16494", .v = -math.f128_true_min }, | 340 | .{ .s = "-0x1p-16494", .v = -math.floatTrueMin(f128) }, |
| 341 | .{ .s = "0x1.edcb34a235253948765432134674fp-1", .v = 0x1.edcb34a235253948765432134674fp-1 }, | 341 | .{ .s = "0x1.edcb34a235253948765432134674fp-1", .v = 0x1.edcb34a235253948765432134674fp-1 }, |
| 342 | }; | 342 | }; |
| 343 | 343 |
lib/std/math.zig+16-32| ... | @@ -45,6 +45,7 @@ pub const floatTrueMin = @import("math/float.zig").floatTrueMin; | ... | @@ -45,6 +45,7 @@ pub const floatTrueMin = @import("math/float.zig").floatTrueMin; |
| 45 | pub const floatMin = @import("math/float.zig").floatMin; | 45 | pub const floatMin = @import("math/float.zig").floatMin; |
| 46 | pub const floatMax = @import("math/float.zig").floatMax; | 46 | pub const floatMax = @import("math/float.zig").floatMax; |
| 47 | pub const floatEps = @import("math/float.zig").floatEps; | 47 | pub const floatEps = @import("math/float.zig").floatEps; |
| 48 | pub const inf = @import("math/float.zig").inf; | ||
| 48 | 49 | ||
| 49 | // TODO Replace with @compileError("deprecated for foobar") after 0.10.0 is released. | 50 | // TODO Replace with @compileError("deprecated for foobar") after 0.10.0 is released. |
| 50 | pub const f16_true_min: comptime_float = floatTrueMin(f16); // prev: 0.000000059604644775390625 | 51 | pub const f16_true_min: comptime_float = floatTrueMin(f16); // prev: 0.000000059604644775390625 |
| ... | @@ -72,6 +73,15 @@ pub const f32_toint: comptime_float = 1.0 / f32_epsilon; // same as before | ... | @@ -72,6 +73,15 @@ pub const f32_toint: comptime_float = 1.0 / f32_epsilon; // same as before |
| 72 | pub const f64_toint: comptime_float = 1.0 / f64_epsilon; // same as before | 73 | pub const f64_toint: comptime_float = 1.0 / f64_epsilon; // same as before |
| 73 | pub const f80_toint = 1.0 / f80_epsilon; // same as before | 74 | pub const f80_toint = 1.0 / f80_epsilon; // same as before |
| 74 | pub const f128_toint = 1.0 / f128_epsilon; // same as before | 75 | pub const f128_toint = 1.0 / f128_epsilon; // same as before |
| 76 | pub const inf_u16 = @bitCast(u16, inf_f16); // prev: @as(u16, 0x7C00) | ||
| 77 | pub const inf_f16 = inf(f16); // prev: @bitCast(f16, inf_u16) | ||
| 78 | pub const inf_u32 = @bitCast(u32, inf_f32); // prev: @as(u32, 0x7F800000) | ||
| 79 | pub const inf_f32 = inf(f32); // prev: @bitCast(f32, inf_u32) | ||
| 80 | pub const inf_u64 = @bitCast(u64, inf_f64); // prev: @as(u64, 0x7FF << 52) | ||
| 81 | pub const inf_f64 = inf(f64); // prev: @bitCast(f64, inf_u64) | ||
| 82 | pub const inf_f80 = inf(f80); // prev: make_f80(F80{ .fraction = 0x8000000000000000, .exp = 0x7fff }) | ||
| 83 | pub const inf_u128 = @bitCast(u128, inf_f128); // prev: @as(u128, 0x7fff0000000000000000000000000000) | ||
| 84 | pub const inf_f128 = inf(f128); // prev: @bitCast(f128, inf_u128) | ||
| 75 | pub const epsilon = floatEps; | 85 | pub const epsilon = floatEps; |
| 76 | // End of "soft deprecated" section | 86 | // End of "soft deprecated" section |
| 77 | 87 | ||
| ... | @@ -81,28 +91,18 @@ pub const nan_f16 = @bitCast(f16, nan_u16); | ... | @@ -81,28 +91,18 @@ pub const nan_f16 = @bitCast(f16, nan_u16); |
| 81 | pub const qnan_u16 = @as(u16, 0x7E00); | 91 | pub const qnan_u16 = @as(u16, 0x7E00); |
| 82 | pub const qnan_f16 = @bitCast(f16, qnan_u16); | 92 | pub const qnan_f16 = @bitCast(f16, qnan_u16); |
| 83 | 93 | ||
| 84 | pub const inf_u16 = @as(u16, 0x7C00); | ||
| 85 | pub const inf_f16 = @bitCast(f16, inf_u16); | ||
| 86 | |||
| 87 | pub const nan_u32 = @as(u32, 0x7F800001); | 94 | pub const nan_u32 = @as(u32, 0x7F800001); |
| 88 | pub const nan_f32 = @bitCast(f32, nan_u32); | 95 | pub const nan_f32 = @bitCast(f32, nan_u32); |
| 89 | 96 | ||
| 90 | pub const qnan_u32 = @as(u32, 0x7FC00000); | 97 | pub const qnan_u32 = @as(u32, 0x7FC00000); |
| 91 | pub const qnan_f32 = @bitCast(f32, qnan_u32); | 98 | pub const qnan_f32 = @bitCast(f32, qnan_u32); |
| 92 | 99 | ||
| 93 | pub const inf_u32 = @as(u32, 0x7F800000); | ||
| 94 | pub const inf_f32 = @bitCast(f32, inf_u32); | ||
| 95 | |||
| 96 | pub const nan_u64 = @as(u64, 0x7FF << 52) | 1; | 100 | pub const nan_u64 = @as(u64, 0x7FF << 52) | 1; |
| 97 | pub const nan_f64 = @bitCast(f64, nan_u64); | 101 | pub const nan_f64 = @bitCast(f64, nan_u64); |
| 98 | 102 | ||
| 99 | pub const qnan_u64 = @as(u64, 0x7ff8000000000000); | 103 | pub const qnan_u64 = @as(u64, 0x7ff8000000000000); |
| 100 | pub const qnan_f64 = @bitCast(f64, qnan_u64); | 104 | pub const qnan_f64 = @bitCast(f64, qnan_u64); |
| 101 | 105 | ||
| 102 | pub const inf_u64 = @as(u64, 0x7FF << 52); | ||
| 103 | pub const inf_f64 = @bitCast(f64, inf_u64); | ||
| 104 | |||
| 105 | pub const inf_f80 = make_f80(F80{ .fraction = 0x8000000000000000, .exp = 0x7fff }); | ||
| 106 | pub const nan_f80 = make_f80(F80{ .fraction = 0xA000000000000000, .exp = 0x7fff }); | 106 | pub const nan_f80 = make_f80(F80{ .fraction = 0xA000000000000000, .exp = 0x7fff }); |
| 107 | pub const qnan_f80 = make_f80(F80{ .fraction = 0xC000000000000000, .exp = 0x7fff }); | 107 | pub const qnan_f80 = make_f80(F80{ .fraction = 0xC000000000000000, .exp = 0x7fff }); |
| 108 | 108 | ||
| ... | @@ -112,12 +112,8 @@ pub const nan_f128 = @bitCast(f128, nan_u128); | ... | @@ -112,12 +112,8 @@ pub const nan_f128 = @bitCast(f128, nan_u128); |
| 112 | pub const qnan_u128 = @as(u128, 0x7fff8000000000000000000000000000); | 112 | pub const qnan_u128 = @as(u128, 0x7fff8000000000000000000000000000); |
| 113 | pub const qnan_f128 = @bitCast(f128, qnan_u128); | 113 | pub const qnan_f128 = @bitCast(f128, qnan_u128); |
| 114 | 114 | ||
| 115 | pub const inf_u128 = @as(u128, 0x7fff0000000000000000000000000000); | ||
| 116 | pub const inf_f128 = @bitCast(f128, inf_u128); | ||
| 117 | |||
| 118 | pub const nan = @import("math/nan.zig").nan; | 115 | pub const nan = @import("math/nan.zig").nan; |
| 119 | pub const snan = @import("math/nan.zig").snan; | 116 | pub const snan = @import("math/nan.zig").snan; |
| 120 | pub const inf = @import("math/inf.zig").inf; | ||
| 121 | 117 | ||
| 122 | /// Performs an approximate comparison of two floating point values `x` and `y`. | 118 | /// Performs an approximate comparison of two floating point values `x` and `y`. |
| 123 | /// Returns true if the absolute difference between them is less or equal than | 119 | /// Returns true if the absolute difference between them is less or equal than |
| ... | @@ -125,7 +121,7 @@ pub const inf = @import("math/inf.zig").inf; | ... | @@ -125,7 +121,7 @@ pub const inf = @import("math/inf.zig").inf; |
| 125 | /// | 121 | /// |
| 126 | /// The `tolerance` parameter is the absolute tolerance used when determining if | 122 | /// The `tolerance` parameter is the absolute tolerance used when determining if |
| 127 | /// the two numbers are close enough; a good value for this parameter is a small | 123 | /// the two numbers are close enough; a good value for this parameter is a small |
| 128 | /// multiple of `epsilon(T)`. | 124 | /// multiple of `floatEps(T)`. |
| 129 | /// | 125 | /// |
| 130 | /// Note that this function is recommended for comparing small numbers | 126 | /// Note that this function is recommended for comparing small numbers |
| 131 | /// around zero; using `approxEqRel` is suggested otherwise. | 127 | /// around zero; using `approxEqRel` is suggested otherwise. |
| ... | @@ -152,7 +148,7 @@ pub fn approxEqAbs(comptime T: type, x: T, y: T, tolerance: T) bool { | ... | @@ -152,7 +148,7 @@ pub fn approxEqAbs(comptime T: type, x: T, y: T, tolerance: T) bool { |
| 152 | /// | 148 | /// |
| 153 | /// The `tolerance` parameter is the relative tolerance used when determining if | 149 | /// The `tolerance` parameter is the relative tolerance used when determining if |
| 154 | /// the two numbers are close enough; a good value for this parameter is usually | 150 | /// the two numbers are close enough; a good value for this parameter is usually |
| 155 | /// `sqrt(epsilon(T))`, meaning that the two numbers are considered equal if at | 151 | /// `sqrt(floatEps(T))`, meaning that the two numbers are considered equal if at |
| 156 | /// least half of the digits are equal. | 152 | /// least half of the digits are equal. |
| 157 | /// | 153 | /// |
| 158 | /// Note that for comparisons of small numbers around zero this function won't | 154 | /// Note that for comparisons of small numbers around zero this function won't |
| ... | @@ -183,25 +179,19 @@ pub fn approxEq(comptime T: type, x: T, y: T, tolerance: T) bool { | ... | @@ -183,25 +179,19 @@ pub fn approxEq(comptime T: type, x: T, y: T, tolerance: T) bool { |
| 183 | 179 | ||
| 184 | test "approxEqAbs and approxEqRel" { | 180 | test "approxEqAbs and approxEqRel" { |
| 185 | inline for ([_]type{ f16, f32, f64, f128 }) |T| { | 181 | inline for ([_]type{ f16, f32, f64, f128 }) |T| { |
| 186 | const eps_value = comptime epsilon(T); | 182 | const eps_value = comptime floatEps(T); |
| 187 | const sqrt_eps_value = comptime sqrt(eps_value); | 183 | const sqrt_eps_value = comptime sqrt(eps_value); |
| 188 | const nan_value = comptime nan(T); | 184 | const nan_value = comptime nan(T); |
| 189 | const inf_value = comptime inf(T); | 185 | const inf_value = comptime inf(T); |
| 190 | const min_value: T = switch (T) { | 186 | const min_value = comptime floatMin(T); |
| 191 | f16 => f16_min, | ||
| 192 | f32 => f32_min, | ||
| 193 | f64 => f64_min, | ||
| 194 | f128 => f128_min, | ||
| 195 | else => unreachable, | ||
| 196 | }; | ||
| 197 | 187 | ||
| 198 | try testing.expect(approxEqAbs(T, 0.0, 0.0, eps_value)); | 188 | try testing.expect(approxEqAbs(T, 0.0, 0.0, eps_value)); |
| 199 | try testing.expect(approxEqAbs(T, -0.0, -0.0, eps_value)); | 189 | try testing.expect(approxEqAbs(T, -0.0, -0.0, eps_value)); |
| 200 | try testing.expect(approxEqAbs(T, 0.0, -0.0, eps_value)); | 190 | try testing.expect(approxEqAbs(T, 0.0, -0.0, eps_value)); |
| 201 | try testing.expect(approxEqRel(T, 1.0, 1.0, sqrt_eps_value)); | 191 | try testing.expect(approxEqRel(T, 1.0, 1.0, sqrt_eps_value)); |
| 202 | try testing.expect(!approxEqRel(T, 1.0, 0.0, sqrt_eps_value)); | 192 | try testing.expect(!approxEqRel(T, 1.0, 0.0, sqrt_eps_value)); |
| 203 | try testing.expect(!approxEqAbs(T, 1.0 + 2 * epsilon(T), 1.0, eps_value)); | 193 | try testing.expect(!approxEqAbs(T, 1.0 + 2 * eps_value, 1.0, eps_value)); |
| 204 | try testing.expect(approxEqAbs(T, 1.0 + 1 * epsilon(T), 1.0, eps_value)); | 194 | try testing.expect(approxEqAbs(T, 1.0 + 1 * eps_value, 1.0, eps_value)); |
| 205 | try testing.expect(!approxEqRel(T, 1.0, nan_value, sqrt_eps_value)); | 195 | try testing.expect(!approxEqRel(T, 1.0, nan_value, sqrt_eps_value)); |
| 206 | try testing.expect(!approxEqRel(T, nan_value, nan_value, sqrt_eps_value)); | 196 | try testing.expect(!approxEqRel(T, nan_value, nan_value, sqrt_eps_value)); |
| 207 | try testing.expect(approxEqRel(T, inf_value, inf_value, sqrt_eps_value)); | 197 | try testing.expect(approxEqRel(T, inf_value, inf_value, sqrt_eps_value)); |
| ... | @@ -1197,12 +1187,6 @@ test "lossyCast" { | ... | @@ -1197,12 +1187,6 @@ test "lossyCast" { |
| 1197 | try testing.expect(lossyCast(u32, @as(f32, maxInt(u32))) == maxInt(u32)); | 1187 | try testing.expect(lossyCast(u32, @as(f32, maxInt(u32))) == maxInt(u32)); |
| 1198 | } | 1188 | } |
| 1199 | 1189 | ||
| 1200 | test "f64_min" { | ||
| 1201 | const f64_min_u64 = 0x0010000000000000; | ||
| 1202 | const fmin: f64 = f64_min; | ||
| 1203 | try testing.expect(@bitCast(u64, fmin) == f64_min_u64); | ||
| 1204 | } | ||
| 1205 | |||
| 1206 | /// Returns the maximum value of integer type T. | 1190 | /// Returns the maximum value of integer type T. |
| 1207 | pub fn maxInt(comptime T: type) comptime_int { | 1191 | pub fn maxInt(comptime T: type) comptime_int { |
| 1208 | const info = @typeInfo(T); | 1192 | const info = @typeInfo(T); |
lib/std/math/__rem_pio2.zig+1-1| ... | @@ -7,7 +7,7 @@ const std = @import("../std.zig"); | ... | @@ -7,7 +7,7 @@ const std = @import("../std.zig"); |
| 7 | const __rem_pio2_large = @import("__rem_pio2_large.zig").__rem_pio2_large; | 7 | const __rem_pio2_large = @import("__rem_pio2_large.zig").__rem_pio2_large; |
| 8 | const math = std.math; | 8 | const math = std.math; |
| 9 | 9 | ||
| 10 | const toint = 1.5 / math.epsilon(f64); | 10 | const toint = 1.5 / math.floatEps(f64); |
| 11 | // pi/4 | 11 | // pi/4 |
| 12 | const pio4 = 0x1.921fb54442d18p-1; | 12 | const pio4 = 0x1.921fb54442d18p-1; |
| 13 | // invpio2: 53 bits of 2/pi | 13 | // invpio2: 53 bits of 2/pi |
lib/std/math/__rem_pio2f.zig+1-1| ... | @@ -7,7 +7,7 @@ const std = @import("../std.zig"); | ... | @@ -7,7 +7,7 @@ const std = @import("../std.zig"); |
| 7 | const __rem_pio2_large = @import("__rem_pio2_large.zig").__rem_pio2_large; | 7 | const __rem_pio2_large = @import("__rem_pio2_large.zig").__rem_pio2_large; |
| 8 | const math = std.math; | 8 | const math = std.math; |
| 9 | 9 | ||
| 10 | const toint = 1.5 / math.epsilon(f64); | 10 | const toint = 1.5 / math.floatEps(f64); |
| 11 | // pi/4 | 11 | // pi/4 |
| 12 | const pio4 = 0x1.921fb6p-1; | 12 | const pio4 = 0x1.921fb6p-1; |
| 13 | // invpio2: 53 bits of 2/pi | 13 | // invpio2: 53 bits of 2/pi |
lib/std/math/ceil.zig+8-4| ... | @@ -62,6 +62,8 @@ fn ceil32(x: f32) f32 { | ... | @@ -62,6 +62,8 @@ fn ceil32(x: f32) f32 { |
| 62 | } | 62 | } |
| 63 | 63 | ||
| 64 | fn ceil64(x: f64) f64 { | 64 | fn ceil64(x: f64) f64 { |
| 65 | const f64_toint = 1.0 / math.floatEps(f64); | ||
| 66 | |||
| 65 | const u = @bitCast(u64, x); | 67 | const u = @bitCast(u64, x); |
| 66 | const e = (u >> 52) & 0x7FF; | 68 | const e = (u >> 52) & 0x7FF; |
| 67 | var y: f64 = undefined; | 69 | var y: f64 = undefined; |
| ... | @@ -71,9 +73,9 @@ fn ceil64(x: f64) f64 { | ... | @@ -71,9 +73,9 @@ fn ceil64(x: f64) f64 { |
| 71 | } | 73 | } |
| 72 | 74 | ||
| 73 | if (u >> 63 != 0) { | 75 | if (u >> 63 != 0) { |
| 74 | y = x - math.f64_toint + math.f64_toint - x; | 76 | y = x - f64_toint + f64_toint - x; |
| 75 | } else { | 77 | } else { |
| 76 | y = x + math.f64_toint - math.f64_toint - x; | 78 | y = x + f64_toint - f64_toint - x; |
| 77 | } | 79 | } |
| 78 | 80 | ||
| 79 | if (e <= 0x3FF - 1) { | 81 | if (e <= 0x3FF - 1) { |
| ... | @@ -91,6 +93,8 @@ fn ceil64(x: f64) f64 { | ... | @@ -91,6 +93,8 @@ fn ceil64(x: f64) f64 { |
| 91 | } | 93 | } |
| 92 | 94 | ||
| 93 | fn ceil128(x: f128) f128 { | 95 | fn ceil128(x: f128) f128 { |
| 96 | const f128_toint = 1.0 / math.floatEps(f128); | ||
| 97 | |||
| 94 | const u = @bitCast(u128, x); | 98 | const u = @bitCast(u128, x); |
| 95 | const e = (u >> 112) & 0x7FFF; | 99 | const e = (u >> 112) & 0x7FFF; |
| 96 | var y: f128 = undefined; | 100 | var y: f128 = undefined; |
| ... | @@ -98,9 +102,9 @@ fn ceil128(x: f128) f128 { | ... | @@ -98,9 +102,9 @@ fn ceil128(x: f128) f128 { |
| 98 | if (e >= 0x3FFF + 112 or x == 0) return x; | 102 | if (e >= 0x3FFF + 112 or x == 0) return x; |
| 99 | 103 | ||
| 100 | if (u >> 127 != 0) { | 104 | if (u >> 127 != 0) { |
| 101 | y = x - math.f128_toint + math.f128_toint - x; | 105 | y = x - f128_toint + f128_toint - x; |
| 102 | } else { | 106 | } else { |
| 103 | y = x + math.f128_toint - math.f128_toint - x; | 107 | y = x + f128_toint - f128_toint - x; |
| 104 | } | 108 | } |
| 105 | 109 | ||
| 106 | if (e <= 0x3FFF - 1) { | 110 | if (e <= 0x3FFF - 1) { |
lib/std/math/complex/exp.zig+2-2| ... | @@ -120,7 +120,7 @@ fn exp64(z: Complex(f64)) Complex(f64) { | ... | @@ -120,7 +120,7 @@ fn exp64(z: Complex(f64)) Complex(f64) { |
| 120 | } | 120 | } |
| 121 | 121 | ||
| 122 | test "complex.cexp32" { | 122 | test "complex.cexp32" { |
| 123 | const tolerance_f32 = math.sqrt(math.epsilon(f32)); | 123 | const tolerance_f32 = math.sqrt(math.floatEps(f32)); |
| 124 | 124 | ||
| 125 | { | 125 | { |
| 126 | const a = Complex(f32).init(5, 3); | 126 | const a = Complex(f32).init(5, 3); |
| ... | @@ -140,7 +140,7 @@ test "complex.cexp32" { | ... | @@ -140,7 +140,7 @@ test "complex.cexp32" { |
| 140 | } | 140 | } |
| 141 | 141 | ||
| 142 | test "complex.cexp64" { | 142 | test "complex.cexp64" { |
| 143 | const tolerance_f64 = math.sqrt(math.epsilon(f64)); | 143 | const tolerance_f64 = math.sqrt(math.floatEps(f64)); |
| 144 | 144 | ||
| 145 | { | 145 | { |
| 146 | const a = Complex(f64).init(5, 3); | 146 | const a = Complex(f64).init(5, 3); |
lib/std/math/complex/sinh.zig+2-2| ... | @@ -79,7 +79,7 @@ fn sinh32(z: Complex(f32)) Complex(f32) { | ... | @@ -79,7 +79,7 @@ fn sinh32(z: Complex(f32)) Complex(f32) { |
| 79 | if (iy >= 0x7f800000) { | 79 | if (iy >= 0x7f800000) { |
| 80 | return Complex(f32).init(x * x, x * (y - y)); | 80 | return Complex(f32).init(x * x, x * (y - y)); |
| 81 | } | 81 | } |
| 82 | return Complex(f32).init(x * math.cos(y), math.inf_f32 * math.sin(y)); | 82 | return Complex(f32).init(x * math.cos(y), math.inf(f32) * math.sin(y)); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | return Complex(f32).init((x * x) * (y - y), (x + x) * (y - y)); | 85 | return Complex(f32).init((x * x) * (y - y), (x + x) * (y - y)); |
| ... | @@ -146,7 +146,7 @@ fn sinh64(z: Complex(f64)) Complex(f64) { | ... | @@ -146,7 +146,7 @@ fn sinh64(z: Complex(f64)) Complex(f64) { |
| 146 | if (iy >= 0x7ff00000) { | 146 | if (iy >= 0x7ff00000) { |
| 147 | return Complex(f64).init(x * x, x * (y - y)); | 147 | return Complex(f64).init(x * x, x * (y - y)); |
| 148 | } | 148 | } |
| 149 | return Complex(f64).init(x * math.cos(y), math.inf_f64 * math.sin(y)); | 149 | return Complex(f64).init(x * math.cos(y), math.inf(f64) * math.sin(y)); |
| 150 | } | 150 | } |
| 151 | 151 | ||
| 152 | return Complex(f64).init((x * x) * (y - y), (x + x) * (y - y)); | 152 | return Complex(f64).init((x * x) * (y - y), (x + x) * (y - y)); |
lib/std/math/float.zig+5| ... | @@ -92,6 +92,11 @@ pub fn floatEps(comptime T: type) T { | ... | @@ -92,6 +92,11 @@ pub fn floatEps(comptime T: type) T { |
| 92 | return reconstructFloat(T, -(floatMantissaDigits(T) - 1), mantissaOne(T)); | 92 | return reconstructFloat(T, -(floatMantissaDigits(T) - 1), mantissaOne(T)); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | /// Returns the value inf for floating point type T. | ||
| 96 | pub fn inf(comptime T: type) T { | ||
| 97 | return reconstructFloat(T, floatExponentMax(T) + 1, mantissaOne(T)); | ||
| 98 | } | ||
| 99 | |||
| 95 | test "std.math.float" { | 100 | test "std.math.float" { |
| 96 | inline for ([_]type{ f16, f32, f64, f80, f128, c_longdouble }) |T| { | 101 | inline for ([_]type{ f16, f32, f64, f80, f128, c_longdouble }) |T| { |
| 97 | // (1 +) for the sign bit, since it is separate from the other bits | 102 | // (1 +) for the sign bit, since it is separate from the other bits |
lib/std/math/floor.zig+8-4| ... | @@ -98,6 +98,8 @@ fn floor32(x: f32) f32 { | ... | @@ -98,6 +98,8 @@ fn floor32(x: f32) f32 { |
| 98 | } | 98 | } |
| 99 | 99 | ||
| 100 | fn floor64(x: f64) f64 { | 100 | fn floor64(x: f64) f64 { |
| 101 | const f64_toint = 1.0 / math.floatEps(f64); | ||
| 102 | |||
| 101 | const u = @bitCast(u64, x); | 103 | const u = @bitCast(u64, x); |
| 102 | const e = (u >> 52) & 0x7FF; | 104 | const e = (u >> 52) & 0x7FF; |
| 103 | var y: f64 = undefined; | 105 | var y: f64 = undefined; |
| ... | @@ -107,9 +109,9 @@ fn floor64(x: f64) f64 { | ... | @@ -107,9 +109,9 @@ fn floor64(x: f64) f64 { |
| 107 | } | 109 | } |
| 108 | 110 | ||
| 109 | if (u >> 63 != 0) { | 111 | if (u >> 63 != 0) { |
| 110 | y = x - math.f64_toint + math.f64_toint - x; | 112 | y = x - f64_toint + f64_toint - x; |
| 111 | } else { | 113 | } else { |
| 112 | y = x + math.f64_toint - math.f64_toint - x; | 114 | y = x + f64_toint - f64_toint - x; |
| 113 | } | 115 | } |
| 114 | 116 | ||
| 115 | if (e <= 0x3FF - 1) { | 117 | if (e <= 0x3FF - 1) { |
| ... | @@ -127,6 +129,8 @@ fn floor64(x: f64) f64 { | ... | @@ -127,6 +129,8 @@ fn floor64(x: f64) f64 { |
| 127 | } | 129 | } |
| 128 | 130 | ||
| 129 | fn floor128(x: f128) f128 { | 131 | fn floor128(x: f128) f128 { |
| 132 | const f128_toint = 1.0 / math.floatEps(f128); | ||
| 133 | |||
| 130 | const u = @bitCast(u128, x); | 134 | const u = @bitCast(u128, x); |
| 131 | const e = (u >> 112) & 0x7FFF; | 135 | const e = (u >> 112) & 0x7FFF; |
| 132 | var y: f128 = undefined; | 136 | var y: f128 = undefined; |
| ... | @@ -134,9 +138,9 @@ fn floor128(x: f128) f128 { | ... | @@ -134,9 +138,9 @@ fn floor128(x: f128) f128 { |
| 134 | if (e >= 0x3FFF + 112 or x == 0) return x; | 138 | if (e >= 0x3FFF + 112 or x == 0) return x; |
| 135 | 139 | ||
| 136 | if (u >> 127 != 0) { | 140 | if (u >> 127 != 0) { |
| 137 | y = x - math.f128_toint + math.f128_toint - x; | 141 | y = x - f128_toint + f128_toint - x; |
| 138 | } else { | 142 | } else { |
| 139 | y = x + math.f128_toint - math.f128_toint - x; | 143 | y = x + f128_toint - f128_toint - x; |
| 140 | } | 144 | } |
| 141 | 145 | ||
| 142 | if (e <= 0x3FFF - 1) { | 146 | if (e <= 0x3FFF - 1) { |
lib/std/math/fma.zig+2-2| ... | @@ -68,7 +68,7 @@ fn fma64(x: f64, y: f64, z: f64) f64 { | ... | @@ -68,7 +68,7 @@ fn fma64(x: f64, y: f64, z: f64) f64 { |
| 68 | if (spread <= 53 * 2) { | 68 | if (spread <= 53 * 2) { |
| 69 | zs = math.scalbn(zs, -spread); | 69 | zs = math.scalbn(zs, -spread); |
| 70 | } else { | 70 | } else { |
| 71 | zs = math.copysign(f64, math.f64_min, zs); | 71 | zs = math.copysign(f64, math.floatMin(f64), zs); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | const xy = dd_mul(xs, ys); | 74 | const xy = dd_mul(xs, ys); |
| ... | @@ -277,7 +277,7 @@ fn fma128(x: f128, y: f128, z: f128) f128 { | ... | @@ -277,7 +277,7 @@ fn fma128(x: f128, y: f128, z: f128) f128 { |
| 277 | if (spread <= 113 * 2) { | 277 | if (spread <= 113 * 2) { |
| 278 | zs = math.scalbn(zs, -spread); | 278 | zs = math.scalbn(zs, -spread); |
| 279 | } else { | 279 | } else { |
| 280 | zs = math.copysign(f128, math.f128_min, zs); | 280 | zs = math.copysign(f128, math.floatMin(f128), zs); |
| 281 | } | 281 | } |
| 282 | 282 | ||
| 283 | const xy = dd_mul128(xs, ys); | 283 | const xy = dd_mul128(xs, ys); |
lib/std/math/inf.zig deleted-14| ... | @@ -1,14 +0,0 @@ | ||
| 1 | const std = @import("../std.zig"); | ||
| 2 | const math = std.math; | ||
| 3 | |||
| 4 | /// Returns value inf for the type T. | ||
| 5 | pub fn inf(comptime T: type) T { | ||
| 6 | return switch (T) { | ||
| 7 | f16 => math.inf_f16, | ||
| 8 | f32 => math.inf_f32, | ||
| 9 | f64 => math.inf_f64, | ||
| 10 | f80 => math.inf_f80, | ||
| 11 | f128 => math.inf_f128, | ||
| 12 | else => @compileError("inf not implemented for " ++ @typeName(T)), | ||
| 13 | }; | ||
| 14 | } | ||
lib/std/math/isfinite.zig+26-45| ... | @@ -1,59 +1,40 @@ | ... | @@ -1,59 +1,40 @@ |
| 1 | const std = @import("../std.zig"); | 1 | const std = @import("../std.zig"); |
| 2 | const math = std.math; | 2 | const math = std.math; |
| 3 | const expect = std.testing.expect; | 3 | const expect = std.testing.expect; |
| 4 | const maxInt = std.math.maxInt; | ||
| 5 | 4 | ||
| 6 | /// Returns whether x is a finite value. | 5 | /// Returns whether x is a finite value. |
| 7 | pub fn isFinite(x: anytype) bool { | 6 | pub fn isFinite(x: anytype) bool { |
| 8 | const T = @TypeOf(x); | 7 | const T = @TypeOf(x); |
| 9 | switch (T) { | 8 | const TBits = std.meta.Int(.unsigned, @bitSizeOf(T)); |
| 10 | f16 => { | 9 | if (@typeInfo(T) != .Float) { |
| 11 | const bits = @bitCast(u16, x); | 10 | @compileError("isFinite not implemented for " ++ @typeName(T)); |
| 12 | return bits & 0x7FFF < 0x7C00; | ||
| 13 | }, | ||
| 14 | f32 => { | ||
| 15 | const bits = @bitCast(u32, x); | ||
| 16 | return bits & 0x7FFFFFFF < 0x7F800000; | ||
| 17 | }, | ||
| 18 | f64 => { | ||
| 19 | const bits = @bitCast(u64, x); | ||
| 20 | return bits & (maxInt(u64) >> 1) < (0x7FF << 52); | ||
| 21 | }, | ||
| 22 | f128 => { | ||
| 23 | const bits = @bitCast(u128, x); | ||
| 24 | return bits & (maxInt(u128) >> 1) < (0x7FFF << 112); | ||
| 25 | }, | ||
| 26 | else => { | ||
| 27 | @compileError("isFinite not implemented for " ++ @typeName(T)); | ||
| 28 | }, | ||
| 29 | } | 11 | } |
| 12 | const remove_sign = ~@as(TBits, 0) >> 1; | ||
| 13 | return @bitCast(TBits, x) & remove_sign < @bitCast(TBits, math.inf(T)); | ||
| 30 | } | 14 | } |
| 31 | 15 | ||
| 32 | test "math.isFinite" { | 16 | test "math.isFinite" { |
| 33 | try expect(isFinite(@as(f16, 0.0))); | 17 | // TODO remove when #11391 is resolved |
| 34 | try expect(isFinite(@as(f16, -0.0))); | 18 | if (@import("builtin").os.tag == .freebsd) return error.SkipZigTest; |
| 35 | try expect(isFinite(@as(f32, 0.0))); | ||
| 36 | try expect(isFinite(@as(f32, -0.0))); | ||
| 37 | try expect(isFinite(@as(f64, 0.0))); | ||
| 38 | try expect(isFinite(@as(f64, -0.0))); | ||
| 39 | try expect(isFinite(@as(f128, 0.0))); | ||
| 40 | try expect(isFinite(@as(f128, -0.0))); | ||
| 41 | 19 | ||
| 42 | try expect(!isFinite(math.inf(f16))); | 20 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { |
| 43 | try expect(!isFinite(-math.inf(f16))); | 21 | // normals |
| 44 | try expect(!isFinite(math.inf(f32))); | 22 | try expect(isFinite(@as(T, 1.0))); |
| 45 | try expect(!isFinite(-math.inf(f32))); | 23 | try expect(isFinite(-@as(T, 1.0))); |
| 46 | try expect(!isFinite(math.inf(f64))); | ||
| 47 | try expect(!isFinite(-math.inf(f64))); | ||
| 48 | try expect(!isFinite(math.inf(f128))); | ||
| 49 | try expect(!isFinite(-math.inf(f128))); | ||
| 50 | 24 | ||
| 51 | try expect(!isFinite(math.nan(f16))); | 25 | // zero & subnormals |
| 52 | try expect(!isFinite(-math.nan(f16))); | 26 | try expect(isFinite(@as(T, 0.0))); |
| 53 | try expect(!isFinite(math.nan(f32))); | 27 | try expect(isFinite(@as(T, -0.0))); |
| 54 | try expect(!isFinite(-math.nan(f32))); | 28 | try expect(isFinite(math.floatTrueMin(T))); |
| 55 | try expect(!isFinite(math.nan(f64))); | 29 | |
| 56 | try expect(!isFinite(-math.nan(f64))); | 30 | // other float limits |
| 57 | try expect(!isFinite(math.nan(f128))); | 31 | try expect(isFinite(math.floatMin(T))); |
| 58 | try expect(!isFinite(-math.nan(f128))); | 32 | try expect(isFinite(math.floatMax(T))); |
| 33 | |||
| 34 | // inf & nan | ||
| 35 | try expect(!isFinite(math.inf(T))); | ||
| 36 | try expect(!isFinite(-math.inf(T))); | ||
| 37 | try expect(!isFinite(math.nan(T))); | ||
| 38 | try expect(!isFinite(-math.nan(T))); | ||
| 39 | } | ||
| 59 | } | 40 | } |
lib/std/math/isinf.zig+40-105| ... | @@ -1,131 +1,66 @@ | ... | @@ -1,131 +1,66 @@ |
| 1 | const std = @import("../std.zig"); | 1 | const std = @import("../std.zig"); |
| 2 | const math = std.math; | 2 | const math = std.math; |
| 3 | const expect = std.testing.expect; | 3 | const expect = std.testing.expect; |
| 4 | const maxInt = std.math.maxInt; | ||
| 5 | 4 | ||
| 6 | /// Returns whether x is an infinity, ignoring sign. | 5 | /// Returns whether x is an infinity, ignoring sign. |
| 7 | pub fn isInf(x: anytype) bool { | 6 | pub fn isInf(x: anytype) bool { |
| 8 | const T = @TypeOf(x); | 7 | const T = @TypeOf(x); |
| 9 | switch (T) { | 8 | const TBits = std.meta.Int(.unsigned, @bitSizeOf(T)); |
| 10 | f16 => { | 9 | if (@typeInfo(T) != .Float) { |
| 11 | const bits = @bitCast(u16, x); | 10 | @compileError("isInf not implemented for " ++ @typeName(T)); |
| 12 | return bits & 0x7FFF == 0x7C00; | ||
| 13 | }, | ||
| 14 | f32 => { | ||
| 15 | const bits = @bitCast(u32, x); | ||
| 16 | return bits & 0x7FFFFFFF == 0x7F800000; | ||
| 17 | }, | ||
| 18 | f64 => { | ||
| 19 | const bits = @bitCast(u64, x); | ||
| 20 | return bits & (maxInt(u64) >> 1) == (0x7FF << 52); | ||
| 21 | }, | ||
| 22 | f128 => { | ||
| 23 | const bits = @bitCast(u128, x); | ||
| 24 | return bits & (maxInt(u128) >> 1) == (0x7FFF << 112); | ||
| 25 | }, | ||
| 26 | else => { | ||
| 27 | @compileError("isInf not implemented for " ++ @typeName(T)); | ||
| 28 | }, | ||
| 29 | } | 11 | } |
| 12 | const remove_sign = ~@as(TBits, 0) >> 1; | ||
| 13 | return @bitCast(TBits, x) & remove_sign == @bitCast(TBits, math.inf(T)); | ||
| 30 | } | 14 | } |
| 31 | 15 | ||
| 32 | /// Returns whether x is an infinity with a positive sign. | 16 | /// Returns whether x is an infinity with a positive sign. |
| 33 | pub fn isPositiveInf(x: anytype) bool { | 17 | pub fn isPositiveInf(x: anytype) bool { |
| 34 | const T = @TypeOf(x); | 18 | return x == math.inf(@TypeOf(x)); |
| 35 | switch (T) { | ||
| 36 | f16 => { | ||
| 37 | return @bitCast(u16, x) == 0x7C00; | ||
| 38 | }, | ||
| 39 | f32 => { | ||
| 40 | return @bitCast(u32, x) == 0x7F800000; | ||
| 41 | }, | ||
| 42 | f64 => { | ||
| 43 | return @bitCast(u64, x) == 0x7FF << 52; | ||
| 44 | }, | ||
| 45 | f128 => { | ||
| 46 | return @bitCast(u128, x) == 0x7FFF << 112; | ||
| 47 | }, | ||
| 48 | else => { | ||
| 49 | @compileError("isPositiveInf not implemented for " ++ @typeName(T)); | ||
| 50 | }, | ||
| 51 | } | ||
| 52 | } | 19 | } |
| 53 | 20 | ||
| 54 | /// Returns whether x is an infinity with a negative sign. | 21 | /// Returns whether x is an infinity with a negative sign. |
| 55 | pub fn isNegativeInf(x: anytype) bool { | 22 | pub fn isNegativeInf(x: anytype) bool { |
| 56 | const T = @TypeOf(x); | 23 | return x == -math.inf(@TypeOf(x)); |
| 57 | switch (T) { | ||
| 58 | f16 => { | ||
| 59 | return @bitCast(u16, x) == 0xFC00; | ||
| 60 | }, | ||
| 61 | f32 => { | ||
| 62 | return @bitCast(u32, x) == 0xFF800000; | ||
| 63 | }, | ||
| 64 | f64 => { | ||
| 65 | return @bitCast(u64, x) == 0xFFF << 52; | ||
| 66 | }, | ||
| 67 | f128 => { | ||
| 68 | return @bitCast(u128, x) == 0xFFFF << 112; | ||
| 69 | }, | ||
| 70 | else => { | ||
| 71 | @compileError("isNegativeInf not implemented for " ++ @typeName(T)); | ||
| 72 | }, | ||
| 73 | } | ||
| 74 | } | 24 | } |
| 75 | 25 | ||
| 76 | test "math.isInf" { | 26 | test "math.isInf" { |
| 77 | try expect(!isInf(@as(f16, 0.0))); | 27 | // TODO remove when #11391 is resolved |
| 78 | try expect(!isInf(@as(f16, -0.0))); | 28 | if (@import("builtin").os.tag == .freebsd) return error.SkipZigTest; |
| 79 | try expect(!isInf(@as(f32, 0.0))); | 29 | |
| 80 | try expect(!isInf(@as(f32, -0.0))); | 30 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { |
| 81 | try expect(!isInf(@as(f64, 0.0))); | 31 | try expect(!isInf(@as(T, 0.0))); |
| 82 | try expect(!isInf(@as(f64, -0.0))); | 32 | try expect(!isInf(@as(T, -0.0))); |
| 83 | try expect(!isInf(@as(f128, 0.0))); | 33 | try expect(isInf(math.inf(T))); |
| 84 | try expect(!isInf(@as(f128, -0.0))); | 34 | try expect(isInf(-math.inf(T))); |
| 85 | try expect(isInf(math.inf(f16))); | 35 | try expect(!isInf(math.nan(T))); |
| 86 | try expect(isInf(-math.inf(f16))); | 36 | try expect(!isInf(-math.nan(T))); |
| 87 | try expect(isInf(math.inf(f32))); | 37 | } |
| 88 | try expect(isInf(-math.inf(f32))); | ||
| 89 | try expect(isInf(math.inf(f64))); | ||
| 90 | try expect(isInf(-math.inf(f64))); | ||
| 91 | try expect(isInf(math.inf(f128))); | ||
| 92 | try expect(isInf(-math.inf(f128))); | ||
| 93 | } | 38 | } |
| 94 | 39 | ||
| 95 | test "math.isPositiveInf" { | 40 | test "math.isPositiveInf" { |
| 96 | try expect(!isPositiveInf(@as(f16, 0.0))); | 41 | // TODO remove when #11391 is resolved |
| 97 | try expect(!isPositiveInf(@as(f16, -0.0))); | 42 | if (@import("builtin").os.tag == .freebsd) return error.SkipZigTest; |
| 98 | try expect(!isPositiveInf(@as(f32, 0.0))); | 43 | |
| 99 | try expect(!isPositiveInf(@as(f32, -0.0))); | 44 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { |
| 100 | try expect(!isPositiveInf(@as(f64, 0.0))); | 45 | try expect(!isPositiveInf(@as(T, 0.0))); |
| 101 | try expect(!isPositiveInf(@as(f64, -0.0))); | 46 | try expect(!isPositiveInf(@as(T, -0.0))); |
| 102 | try expect(!isPositiveInf(@as(f128, 0.0))); | 47 | try expect(isPositiveInf(math.inf(T))); |
| 103 | try expect(!isPositiveInf(@as(f128, -0.0))); | 48 | try expect(!isPositiveInf(-math.inf(T))); |
| 104 | try expect(isPositiveInf(math.inf(f16))); | 49 | try expect(!isInf(math.nan(T))); |
| 105 | try expect(!isPositiveInf(-math.inf(f16))); | 50 | try expect(!isInf(-math.nan(T))); |
| 106 | try expect(isPositiveInf(math.inf(f32))); | 51 | } |
| 107 | try expect(!isPositiveInf(-math.inf(f32))); | ||
| 108 | try expect(isPositiveInf(math.inf(f64))); | ||
| 109 | try expect(!isPositiveInf(-math.inf(f64))); | ||
| 110 | try expect(isPositiveInf(math.inf(f128))); | ||
| 111 | try expect(!isPositiveInf(-math.inf(f128))); | ||
| 112 | } | 52 | } |
| 113 | 53 | ||
| 114 | test "math.isNegativeInf" { | 54 | test "math.isNegativeInf" { |
| 115 | try expect(!isNegativeInf(@as(f16, 0.0))); | 55 | // TODO remove when #11391 is resolved |
| 116 | try expect(!isNegativeInf(@as(f16, -0.0))); | 56 | if (@import("builtin").os.tag == .freebsd) return error.SkipZigTest; |
| 117 | try expect(!isNegativeInf(@as(f32, 0.0))); | 57 | |
| 118 | try expect(!isNegativeInf(@as(f32, -0.0))); | 58 | inline for ([_]type{ f16, f32, f64, f80, f128 }) |T| { |
| 119 | try expect(!isNegativeInf(@as(f64, 0.0))); | 59 | try expect(!isNegativeInf(@as(T, 0.0))); |
| 120 | try expect(!isNegativeInf(@as(f64, -0.0))); | 60 | try expect(!isNegativeInf(@as(T, -0.0))); |
| 121 | try expect(!isNegativeInf(@as(f128, 0.0))); | 61 | try expect(!isNegativeInf(math.inf(T))); |
| 122 | try expect(!isNegativeInf(@as(f128, -0.0))); | 62 | try expect(isNegativeInf(-math.inf(T))); |
| 123 | try expect(!isNegativeInf(math.inf(f16))); | 63 | try expect(!isInf(math.nan(T))); |
| 124 | try expect(isNegativeInf(-math.inf(f16))); | 64 | try expect(!isInf(-math.nan(T))); |
| 125 | try expect(!isNegativeInf(math.inf(f32))); | 65 | } |
| 126 | try expect(isNegativeInf(-math.inf(f32))); | ||
| 127 | try expect(!isNegativeInf(math.inf(f64))); | ||
| 128 | try expect(isNegativeInf(-math.inf(f64))); | ||
| 129 | try expect(!isNegativeInf(math.inf(f128))); | ||
| 130 | try expect(isNegativeInf(-math.inf(f128))); | ||
| 131 | } | 66 | } |
lib/std/math/ldexp.zig+16-14| ... | @@ -57,6 +57,8 @@ pub fn ldexp(x: anytype, n: i32) @TypeOf(x) { | ... | @@ -57,6 +57,8 @@ pub fn ldexp(x: anytype, n: i32) @TypeOf(x) { |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | test "math.ldexp" { | 59 | test "math.ldexp" { |
| 60 | // TODO derive the various constants here with new maths API | ||
| 61 | |||
| 60 | // basic usage | 62 | // basic usage |
| 61 | try expect(ldexp(@as(f16, 1.5), 4) == 24.0); | 63 | try expect(ldexp(@as(f16, 1.5), 4) == 24.0); |
| 62 | try expect(ldexp(@as(f32, 1.5), 4) == 24.0); | 64 | try expect(ldexp(@as(f32, 1.5), 4) == 24.0); |
| ... | @@ -73,20 +75,20 @@ test "math.ldexp" { | ... | @@ -73,20 +75,20 @@ test "math.ldexp" { |
| 73 | try expect(math.isNormal(ldexp(@as(f128, 1.0), -16382))); | 75 | try expect(math.isNormal(ldexp(@as(f128, 1.0), -16382))); |
| 74 | try expect(!math.isNormal(ldexp(@as(f128, 1.0), -16383))); | 76 | try expect(!math.isNormal(ldexp(@as(f128, 1.0), -16383))); |
| 75 | // unreliable due to lack of native f16 support, see talk on PR #8733 | 77 | // unreliable due to lack of native f16 support, see talk on PR #8733 |
| 76 | // try expect(ldexp(@as(f16, 0x1.1FFp-1), -14 - 9) == math.f16_true_min); | 78 | // try expect(ldexp(@as(f16, 0x1.1FFp-1), -14 - 9) == math.floatTrueMin(f16)); |
| 77 | try expect(ldexp(@as(f32, 0x1.3FFFFFp-1), -126 - 22) == math.f32_true_min); | 79 | try expect(ldexp(@as(f32, 0x1.3FFFFFp-1), -126 - 22) == math.floatTrueMin(f32)); |
| 78 | try expect(ldexp(@as(f64, 0x1.7FFFFFFFFFFFFp-1), -1022 - 51) == math.f64_true_min); | 80 | try expect(ldexp(@as(f64, 0x1.7FFFFFFFFFFFFp-1), -1022 - 51) == math.floatTrueMin(f64)); |
| 79 | try expect(ldexp(@as(f128, 0x1.7FFFFFFFFFFFFFFFFFFFFFFFFFFFp-1), -16382 - 111) == math.f128_true_min); | 81 | try expect(ldexp(@as(f128, 0x1.7FFFFFFFFFFFFFFFFFFFFFFFFFFFp-1), -16382 - 111) == math.floatTrueMin(f128)); |
| 80 | 82 | ||
| 81 | // float limits | 83 | // float limits |
| 82 | try expect(ldexp(@as(f32, math.f32_max), -128 - 149) > 0.0); | 84 | try expect(ldexp(math.floatMax(f32), -128 - 149) > 0.0); |
| 83 | try expect(ldexp(@as(f32, math.f32_max), -128 - 149 - 1) == 0.0); | 85 | try expect(ldexp(math.floatMax(f32), -128 - 149 - 1) == 0.0); |
| 84 | try expect(!math.isPositiveInf(ldexp(@as(f16, math.f16_true_min), 15 + 24))); | 86 | try expect(!math.isPositiveInf(ldexp(math.floatTrueMin(f16), 15 + 24))); |
| 85 | try expect(math.isPositiveInf(ldexp(@as(f16, math.f16_true_min), 15 + 24 + 1))); | 87 | try expect(math.isPositiveInf(ldexp(math.floatTrueMin(f16), 15 + 24 + 1))); |
| 86 | try expect(!math.isPositiveInf(ldexp(@as(f32, math.f32_true_min), 127 + 149))); | 88 | try expect(!math.isPositiveInf(ldexp(math.floatTrueMin(f32), 127 + 149))); |
| 87 | try expect(math.isPositiveInf(ldexp(@as(f32, math.f32_true_min), 127 + 149 + 1))); | 89 | try expect(math.isPositiveInf(ldexp(math.floatTrueMin(f32), 127 + 149 + 1))); |
| 88 | try expect(!math.isPositiveInf(ldexp(@as(f64, math.f64_true_min), 1023 + 1074))); | 90 | try expect(!math.isPositiveInf(ldexp(math.floatTrueMin(f64), 1023 + 1074))); |
| 89 | try expect(math.isPositiveInf(ldexp(@as(f64, math.f64_true_min), 1023 + 1074 + 1))); | 91 | try expect(math.isPositiveInf(ldexp(math.floatTrueMin(f64), 1023 + 1074 + 1))); |
| 90 | try expect(!math.isPositiveInf(ldexp(@as(f128, math.f128_true_min), 16383 + 16494))); | 92 | try expect(!math.isPositiveInf(ldexp(math.floatTrueMin(f128), 16383 + 16494))); |
| 91 | try expect(math.isPositiveInf(ldexp(@as(f128, math.f128_true_min), 16383 + 16494 + 1))); | 93 | try expect(math.isPositiveInf(ldexp(math.floatTrueMin(f128), 16383 + 16494 + 1))); |
| 92 | } | 94 | } |
lib/std/math/round.zig+12-6| ... | @@ -29,6 +29,8 @@ pub fn round(x: anytype) @TypeOf(x) { | ... | @@ -29,6 +29,8 @@ pub fn round(x: anytype) @TypeOf(x) { |
| 29 | } | 29 | } |
| 30 | 30 | ||
| 31 | fn round32(x_: f32) f32 { | 31 | fn round32(x_: f32) f32 { |
| 32 | const f32_toint = 1.0 / math.floatEps(f32); | ||
| 33 | |||
| 32 | var x = x_; | 34 | var x = x_; |
| 33 | const u = @bitCast(u32, x); | 35 | const u = @bitCast(u32, x); |
| 34 | const e = (u >> 23) & 0xFF; | 36 | const e = (u >> 23) & 0xFF; |
| ... | @@ -41,11 +43,11 @@ fn round32(x_: f32) f32 { | ... | @@ -41,11 +43,11 @@ fn round32(x_: f32) f32 { |
| 41 | x = -x; | 43 | x = -x; |
| 42 | } | 44 | } |
| 43 | if (e < 0x7F - 1) { | 45 | if (e < 0x7F - 1) { |
| 44 | math.doNotOptimizeAway(x + math.f32_toint); | 46 | math.doNotOptimizeAway(x + f32_toint); |
| 45 | return 0 * @bitCast(f32, u); | 47 | return 0 * @bitCast(f32, u); |
| 46 | } | 48 | } |
| 47 | 49 | ||
| 48 | y = x + math.f32_toint - math.f32_toint - x; | 50 | y = x + f32_toint - f32_toint - x; |
| 49 | if (y > 0.5) { | 51 | if (y > 0.5) { |
| 50 | y = y + x - 1; | 52 | y = y + x - 1; |
| 51 | } else if (y <= -0.5) { | 53 | } else if (y <= -0.5) { |
| ... | @@ -62,6 +64,8 @@ fn round32(x_: f32) f32 { | ... | @@ -62,6 +64,8 @@ fn round32(x_: f32) f32 { |
| 62 | } | 64 | } |
| 63 | 65 | ||
| 64 | fn round64(x_: f64) f64 { | 66 | fn round64(x_: f64) f64 { |
| 67 | const f64_toint = 1.0 / math.floatEps(f64); | ||
| 68 | |||
| 65 | var x = x_; | 69 | var x = x_; |
| 66 | const u = @bitCast(u64, x); | 70 | const u = @bitCast(u64, x); |
| 67 | const e = (u >> 52) & 0x7FF; | 71 | const e = (u >> 52) & 0x7FF; |
| ... | @@ -74,11 +78,11 @@ fn round64(x_: f64) f64 { | ... | @@ -74,11 +78,11 @@ fn round64(x_: f64) f64 { |
| 74 | x = -x; | 78 | x = -x; |
| 75 | } | 79 | } |
| 76 | if (e < 0x3ff - 1) { | 80 | if (e < 0x3ff - 1) { |
| 77 | math.doNotOptimizeAway(x + math.f64_toint); | 81 | math.doNotOptimizeAway(x + f64_toint); |
| 78 | return 0 * @bitCast(f64, u); | 82 | return 0 * @bitCast(f64, u); |
| 79 | } | 83 | } |
| 80 | 84 | ||
| 81 | y = x + math.f64_toint - math.f64_toint - x; | 85 | y = x + f64_toint - f64_toint - x; |
| 82 | if (y > 0.5) { | 86 | if (y > 0.5) { |
| 83 | y = y + x - 1; | 87 | y = y + x - 1; |
| 84 | } else if (y <= -0.5) { | 88 | } else if (y <= -0.5) { |
| ... | @@ -95,6 +99,8 @@ fn round64(x_: f64) f64 { | ... | @@ -95,6 +99,8 @@ fn round64(x_: f64) f64 { |
| 95 | } | 99 | } |
| 96 | 100 | ||
| 97 | fn round128(x_: f128) f128 { | 101 | fn round128(x_: f128) f128 { |
| 102 | const f128_toint = 1.0 / math.floatEps(f128); | ||
| 103 | |||
| 98 | var x = x_; | 104 | var x = x_; |
| 99 | const u = @bitCast(u128, x); | 105 | const u = @bitCast(u128, x); |
| 100 | const e = (u >> 112) & 0x7FFF; | 106 | const e = (u >> 112) & 0x7FFF; |
| ... | @@ -107,11 +113,11 @@ fn round128(x_: f128) f128 { | ... | @@ -107,11 +113,11 @@ fn round128(x_: f128) f128 { |
| 107 | x = -x; | 113 | x = -x; |
| 108 | } | 114 | } |
| 109 | if (e < 0x3FFF - 1) { | 115 | if (e < 0x3FFF - 1) { |
| 110 | math.doNotOptimizeAway(x + math.f64_toint); | 116 | math.doNotOptimizeAway(x + f128_toint); |
| 111 | return 0 * @bitCast(f128, u); | 117 | return 0 * @bitCast(f128, u); |
| 112 | } | 118 | } |
| 113 | 119 | ||
| 114 | y = x + math.f128_toint - math.f128_toint - x; | 120 | y = x + f128_toint - f128_toint - x; |
| 115 | if (y > 0.5) { | 121 | if (y > 0.5) { |
| 116 | y = y + x - 1; | 122 | y = y + x - 1; |
| 117 | } else if (y <= -0.5) { | 123 | } else if (y <= -0.5) { |
lib/std/rand/ziggurat.zig+1-1| ... | @@ -28,7 +28,7 @@ pub fn next_f64(random: Random, comptime tables: ZigTable) f64 { | ... | @@ -28,7 +28,7 @@ pub fn next_f64(random: Random, comptime tables: ZigTable) f64 { |
| 28 | } else { | 28 | } else { |
| 29 | // Generate a value in the range [1, 2) and scale into (0, 1) | 29 | // Generate a value in the range [1, 2) and scale into (0, 1) |
| 30 | const repr = (0x3ff << 52) | (bits >> 12); | 30 | const repr = (0x3ff << 52) | (bits >> 12); |
| 31 | break :blk @bitCast(f64, repr) - (1.0 - math.f64_epsilon / 2.0); | 31 | break :blk @bitCast(f64, repr) - (1.0 - math.floatEps(f64) / 2.0); |
| 32 | } | 32 | } |
| 33 | }; | 33 | }; |
| 34 | 34 |
lib/std/special/compiler_rt/divtf3_test.zig+6-2| ... | @@ -34,8 +34,12 @@ test "divtf3" { | ... | @@ -34,8 +34,12 @@ test "divtf3" { |
| 34 | try test__divtf3(math.qnan_f128, 0x1.23456789abcdefp+5, 0x7fff800000000000, 0); | 34 | try test__divtf3(math.qnan_f128, 0x1.23456789abcdefp+5, 0x7fff800000000000, 0); |
| 35 | // NaN / any = NaN | 35 | // NaN / any = NaN |
| 36 | try test__divtf3(math.nan_f128, 0x1.23456789abcdefp+5, 0x7fff800000000000, 0); | 36 | try test__divtf3(math.nan_f128, 0x1.23456789abcdefp+5, 0x7fff800000000000, 0); |
| 37 | // inf / any = inf | 37 | // inf / any(except inf and nan) = inf |
| 38 | try test__divtf3(math.inf_f128, 0x1.23456789abcdefp+5, 0x7fff000000000000, 0); | 38 | try test__divtf3(math.inf(f128), 0x1.23456789abcdefp+5, 0x7fff000000000000, 0); |
| 39 | // inf / inf = nan | ||
| 40 | try test__divtf3(math.inf(f128), math.inf(f128), 0x7fff800000000000, 0); | ||
| 41 | // inf / nan = nan | ||
| 42 | try test__divtf3(math.inf(f128), math.nan(f128), 0x7fff800000000000, 0); | ||
| 39 | 43 | ||
| 40 | try test__divtf3(0x1.a23b45362464523375893ab4cdefp+5, 0x1.eedcbaba3a94546558237654321fp-1, 0x4004b0b72924d407, 0x0717e84356c6eba2); | 44 | try test__divtf3(0x1.a23b45362464523375893ab4cdefp+5, 0x1.eedcbaba3a94546558237654321fp-1, 0x4004b0b72924d407, 0x0717e84356c6eba2); |
| 41 | try test__divtf3(0x1.a2b34c56d745382f9abf2c3dfeffp-50, 0x1.ed2c3ba15935332532287654321fp-9, 0x3fd5b2af3f828c9b, 0x40e51f64cde8b1f2); | 45 | try test__divtf3(0x1.a2b34c56d745382f9abf2c3dfeffp-50, 0x1.ed2c3ba15935332532287654321fp-9, 0x3fd5b2af3f828c9b, 0x40e51f64cde8b1f2); |
lib/std/special/compiler_rt/fixdfdi_test.zig+4-4| ... | @@ -9,7 +9,7 @@ fn test__fixdfdi(a: f64, expected: i64) !void { | ... | @@ -9,7 +9,7 @@ fn test__fixdfdi(a: f64, expected: i64) !void { |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | test "fixdfdi" { | 11 | test "fixdfdi" { |
| 12 | try test__fixdfdi(-math.f64_max, math.minInt(i64)); | 12 | try test__fixdfdi(-math.floatMax(f64), math.minInt(i64)); |
| 13 | 13 | ||
| 14 | try test__fixdfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64)); | 14 | try test__fixdfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64)); |
| 15 | try test__fixdfdi(-0x1.FFFFFFFFFFFFFp+1023, -0x8000000000000000); | 15 | try test__fixdfdi(-0x1.FFFFFFFFFFFFFp+1023, -0x8000000000000000); |
| ... | @@ -32,9 +32,9 @@ test "fixdfdi" { | ... | @@ -32,9 +32,9 @@ test "fixdfdi" { |
| 32 | try test__fixdfdi(-1.0, -1); | 32 | try test__fixdfdi(-1.0, -1); |
| 33 | try test__fixdfdi(-0.99, 0); | 33 | try test__fixdfdi(-0.99, 0); |
| 34 | try test__fixdfdi(-0.5, 0); | 34 | try test__fixdfdi(-0.5, 0); |
| 35 | try test__fixdfdi(-math.f64_min, 0); | 35 | try test__fixdfdi(-math.floatMin(f64), 0); |
| 36 | try test__fixdfdi(0.0, 0); | 36 | try test__fixdfdi(0.0, 0); |
| 37 | try test__fixdfdi(math.f64_min, 0); | 37 | try test__fixdfdi(math.floatMin(f64), 0); |
| 38 | try test__fixdfdi(0.5, 0); | 38 | try test__fixdfdi(0.5, 0); |
| 39 | try test__fixdfdi(0.99, 0); | 39 | try test__fixdfdi(0.99, 0); |
| 40 | try test__fixdfdi(1.0, 1); | 40 | try test__fixdfdi(1.0, 1); |
| ... | @@ -58,5 +58,5 @@ test "fixdfdi" { | ... | @@ -58,5 +58,5 @@ test "fixdfdi" { |
| 58 | try test__fixdfdi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFF); | 58 | try test__fixdfdi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFF); |
| 59 | try test__fixdfdi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i64)); | 59 | try test__fixdfdi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i64)); |
| 60 | 60 | ||
| 61 | try test__fixdfdi(math.f64_max, math.maxInt(i64)); | 61 | try test__fixdfdi(math.floatMax(f64), math.maxInt(i64)); |
| 62 | } | 62 | } |
lib/std/special/compiler_rt/fixdfsi_test.zig+4-4| ... | @@ -9,7 +9,7 @@ fn test__fixdfsi(a: f64, expected: i32) !void { | ... | @@ -9,7 +9,7 @@ fn test__fixdfsi(a: f64, expected: i32) !void { |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | test "fixdfsi" { | 11 | test "fixdfsi" { |
| 12 | try test__fixdfsi(-math.f64_max, math.minInt(i32)); | 12 | try test__fixdfsi(-math.floatMax(f64), math.minInt(i32)); |
| 13 | 13 | ||
| 14 | try test__fixdfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32)); | 14 | try test__fixdfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32)); |
| 15 | try test__fixdfsi(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000); | 15 | try test__fixdfsi(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000); |
| ... | @@ -36,9 +36,9 @@ test "fixdfsi" { | ... | @@ -36,9 +36,9 @@ test "fixdfsi" { |
| 36 | try test__fixdfsi(-1.0, -1); | 36 | try test__fixdfsi(-1.0, -1); |
| 37 | try test__fixdfsi(-0.99, 0); | 37 | try test__fixdfsi(-0.99, 0); |
| 38 | try test__fixdfsi(-0.5, 0); | 38 | try test__fixdfsi(-0.5, 0); |
| 39 | try test__fixdfsi(-math.f64_min, 0); | 39 | try test__fixdfsi(-math.floatMin(f64), 0); |
| 40 | try test__fixdfsi(0.0, 0); | 40 | try test__fixdfsi(0.0, 0); |
| 41 | try test__fixdfsi(math.f64_min, 0); | 41 | try test__fixdfsi(math.floatMin(f64), 0); |
| 42 | try test__fixdfsi(0.5, 0); | 42 | try test__fixdfsi(0.5, 0); |
| 43 | try test__fixdfsi(0.99, 0); | 43 | try test__fixdfsi(0.99, 0); |
| 44 | try test__fixdfsi(1.0, 1); | 44 | try test__fixdfsi(1.0, 1); |
| ... | @@ -66,5 +66,5 @@ test "fixdfsi" { | ... | @@ -66,5 +66,5 @@ test "fixdfsi" { |
| 66 | try test__fixdfsi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFF); | 66 | try test__fixdfsi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFF); |
| 67 | try test__fixdfsi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i32)); | 67 | try test__fixdfsi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i32)); |
| 68 | 68 | ||
| 69 | try test__fixdfsi(math.f64_max, math.maxInt(i32)); | 69 | try test__fixdfsi(math.floatMax(f64), math.maxInt(i32)); |
| 70 | } | 70 | } |
lib/std/special/compiler_rt/fixdfti_test.zig+4-4| ... | @@ -9,7 +9,7 @@ fn test__fixdfti(a: f64, expected: i128) !void { | ... | @@ -9,7 +9,7 @@ fn test__fixdfti(a: f64, expected: i128) !void { |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | test "fixdfti" { | 11 | test "fixdfti" { |
| 12 | try test__fixdfti(-math.f64_max, math.minInt(i128)); | 12 | try test__fixdfti(-math.floatMax(f64), math.minInt(i128)); |
| 13 | 13 | ||
| 14 | try test__fixdfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128)); | 14 | try test__fixdfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128)); |
| 15 | try test__fixdfti(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000000000000000000000000000); | 15 | try test__fixdfti(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000000000000000000000000000); |
| ... | @@ -32,9 +32,9 @@ test "fixdfti" { | ... | @@ -32,9 +32,9 @@ test "fixdfti" { |
| 32 | try test__fixdfti(-1.0, -1); | 32 | try test__fixdfti(-1.0, -1); |
| 33 | try test__fixdfti(-0.99, 0); | 33 | try test__fixdfti(-0.99, 0); |
| 34 | try test__fixdfti(-0.5, 0); | 34 | try test__fixdfti(-0.5, 0); |
| 35 | try test__fixdfti(-math.f64_min, 0); | 35 | try test__fixdfti(-math.floatMin(f64), 0); |
| 36 | try test__fixdfti(0.0, 0); | 36 | try test__fixdfti(0.0, 0); |
| 37 | try test__fixdfti(math.f64_min, 0); | 37 | try test__fixdfti(math.floatMin(f64), 0); |
| 38 | try test__fixdfti(0.5, 0); | 38 | try test__fixdfti(0.5, 0); |
| 39 | try test__fixdfti(0.99, 0); | 39 | try test__fixdfti(0.99, 0); |
| 40 | try test__fixdfti(1.0, 1); | 40 | try test__fixdfti(1.0, 1); |
| ... | @@ -58,5 +58,5 @@ test "fixdfti" { | ... | @@ -58,5 +58,5 @@ test "fixdfti" { |
| 58 | try test__fixdfti(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); | 58 | try test__fixdfti(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); |
| 59 | try test__fixdfti(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i128)); | 59 | try test__fixdfti(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i128)); |
| 60 | 60 | ||
| 61 | try test__fixdfti(math.f64_max, math.maxInt(i128)); | 61 | try test__fixdfti(math.floatMax(f64), math.maxInt(i128)); |
| 62 | } | 62 | } |
lib/std/special/compiler_rt/fixint_test.zig+36-36| ... | @@ -11,49 +11,49 @@ fn test__fixint(comptime fp_t: type, comptime fixint_t: type, a: fp_t, expected: | ... | @@ -11,49 +11,49 @@ fn test__fixint(comptime fp_t: type, comptime fixint_t: type, a: fp_t, expected: |
| 11 | } | 11 | } |
| 12 | 12 | ||
| 13 | test "fixint.i1" { | 13 | test "fixint.i1" { |
| 14 | try test__fixint(f32, i1, -math.inf_f32, -1); | 14 | try test__fixint(f32, i1, -math.inf(f32), -1); |
| 15 | try test__fixint(f32, i1, -math.f32_max, -1); | 15 | try test__fixint(f32, i1, -math.floatMax(f32), -1); |
| 16 | try test__fixint(f32, i1, -2.0, -1); | 16 | try test__fixint(f32, i1, -2.0, -1); |
| 17 | try test__fixint(f32, i1, -1.1, -1); | 17 | try test__fixint(f32, i1, -1.1, -1); |
| 18 | try test__fixint(f32, i1, -1.0, -1); | 18 | try test__fixint(f32, i1, -1.0, -1); |
| 19 | try test__fixint(f32, i1, -0.9, 0); | 19 | try test__fixint(f32, i1, -0.9, 0); |
| 20 | try test__fixint(f32, i1, -0.1, 0); | 20 | try test__fixint(f32, i1, -0.1, 0); |
| 21 | try test__fixint(f32, i1, -math.f32_min, 0); | 21 | try test__fixint(f32, i1, -math.floatMin(f32), 0); |
| 22 | try test__fixint(f32, i1, -0.0, 0); | 22 | try test__fixint(f32, i1, -0.0, 0); |
| 23 | try test__fixint(f32, i1, 0.0, 0); | 23 | try test__fixint(f32, i1, 0.0, 0); |
| 24 | try test__fixint(f32, i1, math.f32_min, 0); | 24 | try test__fixint(f32, i1, math.floatMin(f32), 0); |
| 25 | try test__fixint(f32, i1, 0.1, 0); | 25 | try test__fixint(f32, i1, 0.1, 0); |
| 26 | try test__fixint(f32, i1, 0.9, 0); | 26 | try test__fixint(f32, i1, 0.9, 0); |
| 27 | try test__fixint(f32, i1, 1.0, 0); | 27 | try test__fixint(f32, i1, 1.0, 0); |
| 28 | try test__fixint(f32, i1, 2.0, 0); | 28 | try test__fixint(f32, i1, 2.0, 0); |
| 29 | try test__fixint(f32, i1, math.f32_max, 0); | 29 | try test__fixint(f32, i1, math.floatMax(f32), 0); |
| 30 | try test__fixint(f32, i1, math.inf_f32, 0); | 30 | try test__fixint(f32, i1, math.inf(f32), 0); |
| 31 | } | 31 | } |
| 32 | 32 | ||
| 33 | test "fixint.i2" { | 33 | test "fixint.i2" { |
| 34 | try test__fixint(f32, i2, -math.inf_f32, -2); | 34 | try test__fixint(f32, i2, -math.inf(f32), -2); |
| 35 | try test__fixint(f32, i2, -math.f32_max, -2); | 35 | try test__fixint(f32, i2, -math.floatMax(f32), -2); |
| 36 | try test__fixint(f32, i2, -2.0, -2); | 36 | try test__fixint(f32, i2, -2.0, -2); |
| 37 | try test__fixint(f32, i2, -1.9, -1); | 37 | try test__fixint(f32, i2, -1.9, -1); |
| 38 | try test__fixint(f32, i2, -1.1, -1); | 38 | try test__fixint(f32, i2, -1.1, -1); |
| 39 | try test__fixint(f32, i2, -1.0, -1); | 39 | try test__fixint(f32, i2, -1.0, -1); |
| 40 | try test__fixint(f32, i2, -0.9, 0); | 40 | try test__fixint(f32, i2, -0.9, 0); |
| 41 | try test__fixint(f32, i2, -0.1, 0); | 41 | try test__fixint(f32, i2, -0.1, 0); |
| 42 | try test__fixint(f32, i2, -math.f32_min, 0); | 42 | try test__fixint(f32, i2, -math.floatMin(f32), 0); |
| 43 | try test__fixint(f32, i2, -0.0, 0); | 43 | try test__fixint(f32, i2, -0.0, 0); |
| 44 | try test__fixint(f32, i2, 0.0, 0); | 44 | try test__fixint(f32, i2, 0.0, 0); |
| 45 | try test__fixint(f32, i2, math.f32_min, 0); | 45 | try test__fixint(f32, i2, math.floatMin(f32), 0); |
| 46 | try test__fixint(f32, i2, 0.1, 0); | 46 | try test__fixint(f32, i2, 0.1, 0); |
| 47 | try test__fixint(f32, i2, 0.9, 0); | 47 | try test__fixint(f32, i2, 0.9, 0); |
| 48 | try test__fixint(f32, i2, 1.0, 1); | 48 | try test__fixint(f32, i2, 1.0, 1); |
| 49 | try test__fixint(f32, i2, 2.0, 1); | 49 | try test__fixint(f32, i2, 2.0, 1); |
| 50 | try test__fixint(f32, i2, math.f32_max, 1); | 50 | try test__fixint(f32, i2, math.floatMax(f32), 1); |
| 51 | try test__fixint(f32, i2, math.inf_f32, 1); | 51 | try test__fixint(f32, i2, math.inf(f32), 1); |
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | test "fixint.i3" { | 54 | test "fixint.i3" { |
| 55 | try test__fixint(f32, i3, -math.inf_f32, -4); | 55 | try test__fixint(f32, i3, -math.inf(f32), -4); |
| 56 | try test__fixint(f32, i3, -math.f32_max, -4); | 56 | try test__fixint(f32, i3, -math.floatMax(f32), -4); |
| 57 | try test__fixint(f32, i3, -4.0, -4); | 57 | try test__fixint(f32, i3, -4.0, -4); |
| 58 | try test__fixint(f32, i3, -3.0, -3); | 58 | try test__fixint(f32, i3, -3.0, -3); |
| 59 | try test__fixint(f32, i3, -2.0, -2); | 59 | try test__fixint(f32, i3, -2.0, -2); |
| ... | @@ -62,23 +62,23 @@ test "fixint.i3" { | ... | @@ -62,23 +62,23 @@ test "fixint.i3" { |
| 62 | try test__fixint(f32, i3, -1.0, -1); | 62 | try test__fixint(f32, i3, -1.0, -1); |
| 63 | try test__fixint(f32, i3, -0.9, 0); | 63 | try test__fixint(f32, i3, -0.9, 0); |
| 64 | try test__fixint(f32, i3, -0.1, 0); | 64 | try test__fixint(f32, i3, -0.1, 0); |
| 65 | try test__fixint(f32, i3, -math.f32_min, 0); | 65 | try test__fixint(f32, i3, -math.floatMin(f32), 0); |
| 66 | try test__fixint(f32, i3, -0.0, 0); | 66 | try test__fixint(f32, i3, -0.0, 0); |
| 67 | try test__fixint(f32, i3, 0.0, 0); | 67 | try test__fixint(f32, i3, 0.0, 0); |
| 68 | try test__fixint(f32, i3, math.f32_min, 0); | 68 | try test__fixint(f32, i3, math.floatMin(f32), 0); |
| 69 | try test__fixint(f32, i3, 0.1, 0); | 69 | try test__fixint(f32, i3, 0.1, 0); |
| 70 | try test__fixint(f32, i3, 0.9, 0); | 70 | try test__fixint(f32, i3, 0.9, 0); |
| 71 | try test__fixint(f32, i3, 1.0, 1); | 71 | try test__fixint(f32, i3, 1.0, 1); |
| 72 | try test__fixint(f32, i3, 2.0, 2); | 72 | try test__fixint(f32, i3, 2.0, 2); |
| 73 | try test__fixint(f32, i3, 3.0, 3); | 73 | try test__fixint(f32, i3, 3.0, 3); |
| 74 | try test__fixint(f32, i3, 4.0, 3); | 74 | try test__fixint(f32, i3, 4.0, 3); |
| 75 | try test__fixint(f32, i3, math.f32_max, 3); | 75 | try test__fixint(f32, i3, math.floatMax(f32), 3); |
| 76 | try test__fixint(f32, i3, math.inf_f32, 3); | 76 | try test__fixint(f32, i3, math.inf(f32), 3); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | test "fixint.i32" { | 79 | test "fixint.i32" { |
| 80 | try test__fixint(f64, i32, -math.inf_f64, math.minInt(i32)); | 80 | try test__fixint(f64, i32, -math.inf(f64), math.minInt(i32)); |
| 81 | try test__fixint(f64, i32, -math.f64_max, math.minInt(i32)); | 81 | try test__fixint(f64, i32, -math.floatMax(f64), math.minInt(i32)); |
| 82 | try test__fixint(f64, i32, @as(f64, math.minInt(i32)), math.minInt(i32)); | 82 | try test__fixint(f64, i32, @as(f64, math.minInt(i32)), math.minInt(i32)); |
| 83 | try test__fixint(f64, i32, @as(f64, math.minInt(i32)) + 1, math.minInt(i32) + 1); | 83 | try test__fixint(f64, i32, @as(f64, math.minInt(i32)) + 1, math.minInt(i32) + 1); |
| 84 | try test__fixint(f64, i32, -2.0, -2); | 84 | try test__fixint(f64, i32, -2.0, -2); |
| ... | @@ -87,22 +87,22 @@ test "fixint.i32" { | ... | @@ -87,22 +87,22 @@ test "fixint.i32" { |
| 87 | try test__fixint(f64, i32, -1.0, -1); | 87 | try test__fixint(f64, i32, -1.0, -1); |
| 88 | try test__fixint(f64, i32, -0.9, 0); | 88 | try test__fixint(f64, i32, -0.9, 0); |
| 89 | try test__fixint(f64, i32, -0.1, 0); | 89 | try test__fixint(f64, i32, -0.1, 0); |
| 90 | try test__fixint(f64, i32, -math.f32_min, 0); | 90 | try test__fixint(f64, i32, -@as(f64, math.floatMin(f32)), 0); |
| 91 | try test__fixint(f64, i32, -0.0, 0); | 91 | try test__fixint(f64, i32, -0.0, 0); |
| 92 | try test__fixint(f64, i32, 0.0, 0); | 92 | try test__fixint(f64, i32, 0.0, 0); |
| 93 | try test__fixint(f64, i32, math.f32_min, 0); | 93 | try test__fixint(f64, i32, @as(f64, math.floatMin(f32)), 0); |
| 94 | try test__fixint(f64, i32, 0.1, 0); | 94 | try test__fixint(f64, i32, 0.1, 0); |
| 95 | try test__fixint(f64, i32, 0.9, 0); | 95 | try test__fixint(f64, i32, 0.9, 0); |
| 96 | try test__fixint(f64, i32, 1.0, 1); | 96 | try test__fixint(f64, i32, 1.0, 1); |
| 97 | try test__fixint(f64, i32, @as(f64, math.maxInt(i32)) - 1, math.maxInt(i32) - 1); | 97 | try test__fixint(f64, i32, @as(f64, math.maxInt(i32)) - 1, math.maxInt(i32) - 1); |
| 98 | try test__fixint(f64, i32, @as(f64, math.maxInt(i32)), math.maxInt(i32)); | 98 | try test__fixint(f64, i32, @as(f64, math.maxInt(i32)), math.maxInt(i32)); |
| 99 | try test__fixint(f64, i32, math.f64_max, math.maxInt(i32)); | 99 | try test__fixint(f64, i32, math.floatMax(f64), math.maxInt(i32)); |
| 100 | try test__fixint(f64, i32, math.inf_f64, math.maxInt(i32)); | 100 | try test__fixint(f64, i32, math.inf(f64), math.maxInt(i32)); |
| 101 | } | 101 | } |
| 102 | 102 | ||
| 103 | test "fixint.i64" { | 103 | test "fixint.i64" { |
| 104 | try test__fixint(f64, i64, -math.inf_f64, math.minInt(i64)); | 104 | try test__fixint(f64, i64, -math.inf(f64), math.minInt(i64)); |
| 105 | try test__fixint(f64, i64, -math.f64_max, math.minInt(i64)); | 105 | try test__fixint(f64, i64, -math.floatMax(f64), math.minInt(i64)); |
| 106 | try test__fixint(f64, i64, @as(f64, math.minInt(i64)), math.minInt(i64)); | 106 | try test__fixint(f64, i64, @as(f64, math.minInt(i64)), math.minInt(i64)); |
| 107 | try test__fixint(f64, i64, @as(f64, math.minInt(i64)) + 1, math.minInt(i64)); | 107 | try test__fixint(f64, i64, @as(f64, math.minInt(i64)) + 1, math.minInt(i64)); |
| 108 | try test__fixint(f64, i64, @as(f64, math.minInt(i64) / 2), math.minInt(i64) / 2); | 108 | try test__fixint(f64, i64, @as(f64, math.minInt(i64) / 2), math.minInt(i64) / 2); |
| ... | @@ -112,22 +112,22 @@ test "fixint.i64" { | ... | @@ -112,22 +112,22 @@ test "fixint.i64" { |
| 112 | try test__fixint(f64, i64, -1.0, -1); | 112 | try test__fixint(f64, i64, -1.0, -1); |
| 113 | try test__fixint(f64, i64, -0.9, 0); | 113 | try test__fixint(f64, i64, -0.9, 0); |
| 114 | try test__fixint(f64, i64, -0.1, 0); | 114 | try test__fixint(f64, i64, -0.1, 0); |
| 115 | try test__fixint(f64, i64, -math.f32_min, 0); | 115 | try test__fixint(f64, i64, -@as(f64, math.floatMin(f32)), 0); |
| 116 | try test__fixint(f64, i64, -0.0, 0); | 116 | try test__fixint(f64, i64, -0.0, 0); |
| 117 | try test__fixint(f64, i64, 0.0, 0); | 117 | try test__fixint(f64, i64, 0.0, 0); |
| 118 | try test__fixint(f64, i64, math.f32_min, 0); | 118 | try test__fixint(f64, i64, @as(f64, math.floatMin(f32)), 0); |
| 119 | try test__fixint(f64, i64, 0.1, 0); | 119 | try test__fixint(f64, i64, 0.1, 0); |
| 120 | try test__fixint(f64, i64, 0.9, 0); | 120 | try test__fixint(f64, i64, 0.9, 0); |
| 121 | try test__fixint(f64, i64, 1.0, 1); | 121 | try test__fixint(f64, i64, 1.0, 1); |
| 122 | try test__fixint(f64, i64, @as(f64, math.maxInt(i64)) - 1, math.maxInt(i64)); | 122 | try test__fixint(f64, i64, @as(f64, math.maxInt(i64)) - 1, math.maxInt(i64)); |
| 123 | try test__fixint(f64, i64, @as(f64, math.maxInt(i64)), math.maxInt(i64)); | 123 | try test__fixint(f64, i64, @as(f64, math.maxInt(i64)), math.maxInt(i64)); |
| 124 | try test__fixint(f64, i64, math.f64_max, math.maxInt(i64)); | 124 | try test__fixint(f64, i64, math.floatMax(f64), math.maxInt(i64)); |
| 125 | try test__fixint(f64, i64, math.inf_f64, math.maxInt(i64)); | 125 | try test__fixint(f64, i64, math.inf(f64), math.maxInt(i64)); |
| 126 | } | 126 | } |
| 127 | 127 | ||
| 128 | test "fixint.i128" { | 128 | test "fixint.i128" { |
| 129 | try test__fixint(f64, i128, -math.inf_f64, math.minInt(i128)); | 129 | try test__fixint(f64, i128, -math.inf(f64), math.minInt(i128)); |
| 130 | try test__fixint(f64, i128, -math.f64_max, math.minInt(i128)); | 130 | try test__fixint(f64, i128, -math.floatMax(f64), math.minInt(i128)); |
| 131 | try test__fixint(f64, i128, @as(f64, math.minInt(i128)), math.minInt(i128)); | 131 | try test__fixint(f64, i128, @as(f64, math.minInt(i128)), math.minInt(i128)); |
| 132 | try test__fixint(f64, i128, @as(f64, math.minInt(i128)) + 1, math.minInt(i128)); | 132 | try test__fixint(f64, i128, @as(f64, math.minInt(i128)) + 1, math.minInt(i128)); |
| 133 | try test__fixint(f64, i128, -2.0, -2); | 133 | try test__fixint(f64, i128, -2.0, -2); |
| ... | @@ -136,15 +136,15 @@ test "fixint.i128" { | ... | @@ -136,15 +136,15 @@ test "fixint.i128" { |
| 136 | try test__fixint(f64, i128, -1.0, -1); | 136 | try test__fixint(f64, i128, -1.0, -1); |
| 137 | try test__fixint(f64, i128, -0.9, 0); | 137 | try test__fixint(f64, i128, -0.9, 0); |
| 138 | try test__fixint(f64, i128, -0.1, 0); | 138 | try test__fixint(f64, i128, -0.1, 0); |
| 139 | try test__fixint(f64, i128, -math.f32_min, 0); | 139 | try test__fixint(f64, i128, -@as(f64, math.floatMin(f32)), 0); |
| 140 | try test__fixint(f64, i128, -0.0, 0); | 140 | try test__fixint(f64, i128, -0.0, 0); |
| 141 | try test__fixint(f64, i128, 0.0, 0); | 141 | try test__fixint(f64, i128, 0.0, 0); |
| 142 | try test__fixint(f64, i128, math.f32_min, 0); | 142 | try test__fixint(f64, i128, @as(f64, math.floatMin(f32)), 0); |
| 143 | try test__fixint(f64, i128, 0.1, 0); | 143 | try test__fixint(f64, i128, 0.1, 0); |
| 144 | try test__fixint(f64, i128, 0.9, 0); | 144 | try test__fixint(f64, i128, 0.9, 0); |
| 145 | try test__fixint(f64, i128, 1.0, 1); | 145 | try test__fixint(f64, i128, 1.0, 1); |
| 146 | try test__fixint(f64, i128, @as(f64, math.maxInt(i128)) - 1, math.maxInt(i128)); | 146 | try test__fixint(f64, i128, @as(f64, math.maxInt(i128)) - 1, math.maxInt(i128)); |
| 147 | try test__fixint(f64, i128, @as(f64, math.maxInt(i128)), math.maxInt(i128)); | 147 | try test__fixint(f64, i128, @as(f64, math.maxInt(i128)), math.maxInt(i128)); |
| 148 | try test__fixint(f64, i128, math.f64_max, math.maxInt(i128)); | 148 | try test__fixint(f64, i128, math.floatMax(f64), math.maxInt(i128)); |
| 149 | try test__fixint(f64, i128, math.inf_f64, math.maxInt(i128)); | 149 | try test__fixint(f64, i128, math.inf(f64), math.maxInt(i128)); |
| 150 | } | 150 | } |
lib/std/special/compiler_rt/fixsfdi_test.zig+4-4| ... | @@ -9,7 +9,7 @@ fn test__fixsfdi(a: f32, expected: i64) !void { | ... | @@ -9,7 +9,7 @@ fn test__fixsfdi(a: f32, expected: i64) !void { |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | test "fixsfdi" { | 11 | test "fixsfdi" { |
| 12 | try test__fixsfdi(-math.f32_max, math.minInt(i64)); | 12 | try test__fixsfdi(-math.floatMax(f32), math.minInt(i64)); |
| 13 | 13 | ||
| 14 | try test__fixsfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64)); | 14 | try test__fixsfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64)); |
| 15 | try test__fixsfdi(-0x1.FFFFFFFFFFFFFp+1023, -0x8000000000000000); | 15 | try test__fixsfdi(-0x1.FFFFFFFFFFFFFp+1023, -0x8000000000000000); |
| ... | @@ -33,9 +33,9 @@ test "fixsfdi" { | ... | @@ -33,9 +33,9 @@ test "fixsfdi" { |
| 33 | try test__fixsfdi(-1.0, -1); | 33 | try test__fixsfdi(-1.0, -1); |
| 34 | try test__fixsfdi(-0.99, 0); | 34 | try test__fixsfdi(-0.99, 0); |
| 35 | try test__fixsfdi(-0.5, 0); | 35 | try test__fixsfdi(-0.5, 0); |
| 36 | try test__fixsfdi(-math.f32_min, 0); | 36 | try test__fixsfdi(-math.floatMin(f32), 0); |
| 37 | try test__fixsfdi(0.0, 0); | 37 | try test__fixsfdi(0.0, 0); |
| 38 | try test__fixsfdi(math.f32_min, 0); | 38 | try test__fixsfdi(math.floatMin(f32), 0); |
| 39 | try test__fixsfdi(0.5, 0); | 39 | try test__fixsfdi(0.5, 0); |
| 40 | try test__fixsfdi(0.99, 0); | 40 | try test__fixsfdi(0.99, 0); |
| 41 | try test__fixsfdi(1.0, 1); | 41 | try test__fixsfdi(1.0, 1); |
| ... | @@ -60,5 +60,5 @@ test "fixsfdi" { | ... | @@ -60,5 +60,5 @@ test "fixsfdi" { |
| 60 | try test__fixsfdi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFF); | 60 | try test__fixsfdi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFF); |
| 61 | try test__fixsfdi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i64)); | 61 | try test__fixsfdi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i64)); |
| 62 | 62 | ||
| 63 | try test__fixsfdi(math.f64_max, math.maxInt(i64)); | 63 | try test__fixsfdi(math.floatMax(f32), math.maxInt(i64)); |
| 64 | } | 64 | } |
lib/std/special/compiler_rt/fixsfsi_test.zig+4-4| ... | @@ -9,7 +9,7 @@ fn test__fixsfsi(a: f32, expected: i32) !void { | ... | @@ -9,7 +9,7 @@ fn test__fixsfsi(a: f32, expected: i32) !void { |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | test "fixsfsi" { | 11 | test "fixsfsi" { |
| 12 | try test__fixsfsi(-math.f32_max, math.minInt(i32)); | 12 | try test__fixsfsi(-math.floatMax(f32), math.minInt(i32)); |
| 13 | 13 | ||
| 14 | try test__fixsfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32)); | 14 | try test__fixsfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32)); |
| 15 | try test__fixsfsi(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000); | 15 | try test__fixsfsi(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000); |
| ... | @@ -37,9 +37,9 @@ test "fixsfsi" { | ... | @@ -37,9 +37,9 @@ test "fixsfsi" { |
| 37 | try test__fixsfsi(-1.0, -1); | 37 | try test__fixsfsi(-1.0, -1); |
| 38 | try test__fixsfsi(-0.99, 0); | 38 | try test__fixsfsi(-0.99, 0); |
| 39 | try test__fixsfsi(-0.5, 0); | 39 | try test__fixsfsi(-0.5, 0); |
| 40 | try test__fixsfsi(-math.f32_min, 0); | 40 | try test__fixsfsi(-math.floatMin(f32), 0); |
| 41 | try test__fixsfsi(0.0, 0); | 41 | try test__fixsfsi(0.0, 0); |
| 42 | try test__fixsfsi(math.f32_min, 0); | 42 | try test__fixsfsi(math.floatMin(f32), 0); |
| 43 | try test__fixsfsi(0.5, 0); | 43 | try test__fixsfsi(0.5, 0); |
| 44 | try test__fixsfsi(0.99, 0); | 44 | try test__fixsfsi(0.99, 0); |
| 45 | try test__fixsfsi(1.0, 1); | 45 | try test__fixsfsi(1.0, 1); |
| ... | @@ -68,5 +68,5 @@ test "fixsfsi" { | ... | @@ -68,5 +68,5 @@ test "fixsfsi" { |
| 68 | try test__fixsfsi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFF); | 68 | try test__fixsfsi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFF); |
| 69 | try test__fixsfsi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i32)); | 69 | try test__fixsfsi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i32)); |
| 70 | 70 | ||
| 71 | try test__fixsfsi(math.f32_max, math.maxInt(i32)); | 71 | try test__fixsfsi(math.floatMax(f32), math.maxInt(i32)); |
| 72 | } | 72 | } |
lib/std/special/compiler_rt/fixsfti_test.zig+4-4| ... | @@ -9,7 +9,7 @@ fn test__fixsfti(a: f32, expected: i128) !void { | ... | @@ -9,7 +9,7 @@ fn test__fixsfti(a: f32, expected: i128) !void { |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | test "fixsfti" { | 11 | test "fixsfti" { |
| 12 | try test__fixsfti(-math.f32_max, math.minInt(i128)); | 12 | try test__fixsfti(-math.floatMax(f32), math.minInt(i128)); |
| 13 | 13 | ||
| 14 | try test__fixsfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128)); | 14 | try test__fixsfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128)); |
| 15 | try test__fixsfti(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000000000000000000000000000); | 15 | try test__fixsfti(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000000000000000000000000000); |
| ... | @@ -41,9 +41,9 @@ test "fixsfti" { | ... | @@ -41,9 +41,9 @@ test "fixsfti" { |
| 41 | try test__fixsfti(-1.0, -1); | 41 | try test__fixsfti(-1.0, -1); |
| 42 | try test__fixsfti(-0.99, 0); | 42 | try test__fixsfti(-0.99, 0); |
| 43 | try test__fixsfti(-0.5, 0); | 43 | try test__fixsfti(-0.5, 0); |
| 44 | try test__fixsfti(-math.f32_min, 0); | 44 | try test__fixsfti(-math.floatMin(f32), 0); |
| 45 | try test__fixsfti(0.0, 0); | 45 | try test__fixsfti(0.0, 0); |
| 46 | try test__fixsfti(math.f32_min, 0); | 46 | try test__fixsfti(math.floatMin(f32), 0); |
| 47 | try test__fixsfti(0.5, 0); | 47 | try test__fixsfti(0.5, 0); |
| 48 | try test__fixsfti(0.99, 0); | 48 | try test__fixsfti(0.99, 0); |
| 49 | try test__fixsfti(1.0, 1); | 49 | try test__fixsfti(1.0, 1); |
| ... | @@ -76,5 +76,5 @@ test "fixsfti" { | ... | @@ -76,5 +76,5 @@ test "fixsfti" { |
| 76 | try test__fixsfti(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); | 76 | try test__fixsfti(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); |
| 77 | try test__fixsfti(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i128)); | 77 | try test__fixsfti(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i128)); |
| 78 | 78 | ||
| 79 | try test__fixsfti(math.f32_max, math.maxInt(i128)); | 79 | try test__fixsfti(math.floatMax(f32), math.maxInt(i128)); |
| 80 | } | 80 | } |
lib/std/special/compiler_rt/fixtfdi_test.zig+4-4| ... | @@ -9,7 +9,7 @@ fn test__fixtfdi(a: f128, expected: i64) !void { | ... | @@ -9,7 +9,7 @@ fn test__fixtfdi(a: f128, expected: i64) !void { |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | test "fixtfdi" { | 11 | test "fixtfdi" { |
| 12 | try test__fixtfdi(-math.f128_max, math.minInt(i64)); | 12 | try test__fixtfdi(-math.floatMax(f128), math.minInt(i64)); |
| 13 | 13 | ||
| 14 | try test__fixtfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64)); | 14 | try test__fixtfdi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i64)); |
| 15 | try test__fixtfdi(-0x1.FFFFFFFFFFFFFp+1023, -0x8000000000000000); | 15 | try test__fixtfdi(-0x1.FFFFFFFFFFFFFp+1023, -0x8000000000000000); |
| ... | @@ -37,9 +37,9 @@ test "fixtfdi" { | ... | @@ -37,9 +37,9 @@ test "fixtfdi" { |
| 37 | try test__fixtfdi(-1.0, -1); | 37 | try test__fixtfdi(-1.0, -1); |
| 38 | try test__fixtfdi(-0.99, 0); | 38 | try test__fixtfdi(-0.99, 0); |
| 39 | try test__fixtfdi(-0.5, 0); | 39 | try test__fixtfdi(-0.5, 0); |
| 40 | try test__fixtfdi(-math.f64_min, 0); | 40 | try test__fixtfdi(-@as(f128, math.floatMin(f64)), 0); |
| 41 | try test__fixtfdi(0.0, 0); | 41 | try test__fixtfdi(0.0, 0); |
| 42 | try test__fixtfdi(math.f64_min, 0); | 42 | try test__fixtfdi(@as(f128, math.floatMin(f64)), 0); |
| 43 | try test__fixtfdi(0.5, 0); | 43 | try test__fixtfdi(0.5, 0); |
| 44 | try test__fixtfdi(0.99, 0); | 44 | try test__fixtfdi(0.99, 0); |
| 45 | try test__fixtfdi(1.0, 1); | 45 | try test__fixtfdi(1.0, 1); |
| ... | @@ -68,5 +68,5 @@ test "fixtfdi" { | ... | @@ -68,5 +68,5 @@ test "fixtfdi" { |
| 68 | try test__fixtfdi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFF); | 68 | try test__fixtfdi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFF); |
| 69 | try test__fixtfdi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i64)); | 69 | try test__fixtfdi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i64)); |
| 70 | 70 | ||
| 71 | try test__fixtfdi(math.f128_max, math.maxInt(i64)); | 71 | try test__fixtfdi(math.floatMax(f128), math.maxInt(i64)); |
| 72 | } | 72 | } |
lib/std/special/compiler_rt/fixtfsi_test.zig+4-4| ... | @@ -9,7 +9,7 @@ fn test__fixtfsi(a: f128, expected: i32) !void { | ... | @@ -9,7 +9,7 @@ fn test__fixtfsi(a: f128, expected: i32) !void { |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | test "fixtfsi" { | 11 | test "fixtfsi" { |
| 12 | try test__fixtfsi(-math.f128_max, math.minInt(i32)); | 12 | try test__fixtfsi(-math.floatMax(f128), math.minInt(i32)); |
| 13 | 13 | ||
| 14 | try test__fixtfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32)); | 14 | try test__fixtfsi(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i32)); |
| 15 | try test__fixtfsi(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000); | 15 | try test__fixtfsi(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000); |
| ... | @@ -37,9 +37,9 @@ test "fixtfsi" { | ... | @@ -37,9 +37,9 @@ test "fixtfsi" { |
| 37 | try test__fixtfsi(-1.0, -1); | 37 | try test__fixtfsi(-1.0, -1); |
| 38 | try test__fixtfsi(-0.99, 0); | 38 | try test__fixtfsi(-0.99, 0); |
| 39 | try test__fixtfsi(-0.5, 0); | 39 | try test__fixtfsi(-0.5, 0); |
| 40 | try test__fixtfsi(-math.f32_min, 0); | 40 | try test__fixtfsi(-@as(f128, math.floatMin(f32)), 0); |
| 41 | try test__fixtfsi(0.0, 0); | 41 | try test__fixtfsi(0.0, 0); |
| 42 | try test__fixtfsi(math.f32_min, 0); | 42 | try test__fixtfsi(@as(f128, math.floatMin(f32)), 0); |
| 43 | try test__fixtfsi(0.5, 0); | 43 | try test__fixtfsi(0.5, 0); |
| 44 | try test__fixtfsi(0.99, 0); | 44 | try test__fixtfsi(0.99, 0); |
| 45 | try test__fixtfsi(1.0, 1); | 45 | try test__fixtfsi(1.0, 1); |
| ... | @@ -68,5 +68,5 @@ test "fixtfsi" { | ... | @@ -68,5 +68,5 @@ test "fixtfsi" { |
| 68 | try test__fixtfsi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFF); | 68 | try test__fixtfsi(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFF); |
| 69 | try test__fixtfsi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i32)); | 69 | try test__fixtfsi(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i32)); |
| 70 | 70 | ||
| 71 | try test__fixtfsi(math.f128_max, math.maxInt(i32)); | 71 | try test__fixtfsi(math.floatMax(f128), math.maxInt(i32)); |
| 72 | } | 72 | } |
lib/std/special/compiler_rt/fixtfti_test.zig+4-4| ... | @@ -9,7 +9,7 @@ fn test__fixtfti(a: f128, expected: i128) !void { | ... | @@ -9,7 +9,7 @@ fn test__fixtfti(a: f128, expected: i128) !void { |
| 9 | } | 9 | } |
| 10 | 10 | ||
| 11 | test "fixtfti" { | 11 | test "fixtfti" { |
| 12 | try test__fixtfti(-math.f128_max, math.minInt(i128)); | 12 | try test__fixtfti(-math.floatMax(f128), math.minInt(i128)); |
| 13 | 13 | ||
| 14 | try test__fixtfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128)); | 14 | try test__fixtfti(-0x1.FFFFFFFFFFFFFp+1023, math.minInt(i128)); |
| 15 | try test__fixtfti(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000000000000000000000000000); | 15 | try test__fixtfti(-0x1.FFFFFFFFFFFFFp+1023, -0x80000000000000000000000000000000); |
| ... | @@ -32,9 +32,9 @@ test "fixtfti" { | ... | @@ -32,9 +32,9 @@ test "fixtfti" { |
| 32 | try test__fixtfti(-1.0, -1); | 32 | try test__fixtfti(-1.0, -1); |
| 33 | try test__fixtfti(-0.99, 0); | 33 | try test__fixtfti(-0.99, 0); |
| 34 | try test__fixtfti(-0.5, 0); | 34 | try test__fixtfti(-0.5, 0); |
| 35 | try test__fixtfti(-math.f128_min, 0); | 35 | try test__fixtfti(-math.floatMin(f128), 0); |
| 36 | try test__fixtfti(0.0, 0); | 36 | try test__fixtfti(0.0, 0); |
| 37 | try test__fixtfti(math.f128_min, 0); | 37 | try test__fixtfti(math.floatMin(f128), 0); |
| 38 | try test__fixtfti(0.5, 0); | 38 | try test__fixtfti(0.5, 0); |
| 39 | try test__fixtfti(0.99, 0); | 39 | try test__fixtfti(0.99, 0); |
| 40 | try test__fixtfti(1.0, 1); | 40 | try test__fixtfti(1.0, 1); |
| ... | @@ -58,5 +58,5 @@ test "fixtfti" { | ... | @@ -58,5 +58,5 @@ test "fixtfti" { |
| 58 | try test__fixtfti(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); | 58 | try test__fixtfti(0x1.FFFFFFFFFFFFFp+1023, 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF); |
| 59 | try test__fixtfti(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i128)); | 59 | try test__fixtfti(0x1.FFFFFFFFFFFFFp+1023, math.maxInt(i128)); |
| 60 | 60 | ||
| 61 | try test__fixtfti(math.f128_max, math.maxInt(i128)); | 61 | try test__fixtfti(math.floatMax(f128), math.maxInt(i128)); |
| 62 | } | 62 | } |
lib/std/special/compiler_rt/floatfmodl_test.zig+4-4| ... | @@ -15,10 +15,10 @@ fn test_fmodl_nans() !void { | ... | @@ -15,10 +15,10 @@ fn test_fmodl_nans() !void { |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | fn test_fmodl_infs() !void { | 17 | fn test_fmodl_infs() !void { |
| 18 | try testing.expect(fmodl.fmodl(1.0, std.math.inf_f128) == 1.0); | 18 | try testing.expect(fmodl.fmodl(1.0, std.math.inf(f128)) == 1.0); |
| 19 | try testing.expect(fmodl.fmodl(1.0, -std.math.inf_f128) == 1.0); | 19 | try testing.expect(fmodl.fmodl(1.0, -std.math.inf(f128)) == 1.0); |
| 20 | try testing.expect(std.math.isNan(fmodl.fmodl(std.math.inf_f128, 1.0))); | 20 | try testing.expect(std.math.isNan(fmodl.fmodl(std.math.inf(f128), 1.0))); |
| 21 | try testing.expect(std.math.isNan(fmodl.fmodl(-std.math.inf_f128, 1.0))); | 21 | try testing.expect(std.math.isNan(fmodl.fmodl(-std.math.inf(f128), 1.0))); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | test "fmodl" { | 24 | test "fmodl" { |
test/behavior/vector.zig+1-1| ... | @@ -641,7 +641,7 @@ test "vector reduce operation" { | ... | @@ -641,7 +641,7 @@ test "vector reduce operation" { |
| 641 | // equal. | 641 | // equal. |
| 642 | } else { | 642 | } else { |
| 643 | const F = @TypeOf(expected); | 643 | const F = @TypeOf(expected); |
| 644 | const tolerance = @sqrt(math.epsilon(TX)); | 644 | const tolerance = @sqrt(math.floatEps(TX)); |
| 645 | try expect(std.math.approxEqRel(F, expected, r, tolerance)); | 645 | try expect(std.math.approxEqRel(F, expected, r, tolerance)); |
| 646 | } | 646 | } |
| 647 | }, | 647 | }, |