std.math: hard deprecate obsolete constants (soft deprecated in 0.10)

Followup to 5b8ac9821dd25c3e5282130b4d93d6c5b7debb08.
Signed-off-by: Eric Joldasov <bratishkaerik@getgoogleoff.me>
This commit is contained in:
Eric Joldasov 2023-06-04 23:09:17 +06:00
parent eb4439f1e4
commit d04a262a3d
No known key found for this signature in database
GPG Key ID: 5C9C69060686B588
5 changed files with 343 additions and 255 deletions

View File

@ -32,17 +32,18 @@ fn test__powixf2(a: f80, b: i32, expected: f80) !void {
}
test "powihf2" {
const inf_f16 = math.inf(f16);
try test__powisf2(0, 0, 1);
try test__powihf2(1, 0, 1);
try test__powihf2(1.5, 0, 1);
try test__powihf2(2, 0, 1);
try test__powihf2(math.inf_f16, 0, 1);
try test__powihf2(inf_f16, 0, 1);
try test__powihf2(-0.0, 0, 1);
try test__powihf2(-1, 0, 1);
try test__powihf2(-1.5, 0, 1);
try test__powihf2(-2, 0, 1);
try test__powihf2(-math.inf_f16, 0, 1);
try test__powihf2(-inf_f16, 0, 1);
try test__powihf2(0, 1, 0);
try test__powihf2(0, 2, 0);
@ -65,35 +66,35 @@ test "powihf2" {
try test__powihf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFE)), 1);
try test__powihf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFF)), 1);
try test__powihf2(math.inf_f16, 1, math.inf_f16);
try test__powihf2(math.inf_f16, 2, math.inf_f16);
try test__powihf2(math.inf_f16, 3, math.inf_f16);
try test__powihf2(math.inf_f16, 4, math.inf_f16);
try test__powihf2(math.inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f16);
try test__powihf2(math.inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFF)), math.inf_f16);
try test__powihf2(inf_f16, 1, inf_f16);
try test__powihf2(inf_f16, 2, inf_f16);
try test__powihf2(inf_f16, 3, inf_f16);
try test__powihf2(inf_f16, 4, inf_f16);
try test__powihf2(inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f16);
try test__powihf2(inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFF)), inf_f16);
try test__powihf2(-math.inf_f16, 1, -math.inf_f16);
try test__powihf2(-math.inf_f16, 2, math.inf_f16);
try test__powihf2(-math.inf_f16, 3, -math.inf_f16);
try test__powihf2(-math.inf_f16, 4, math.inf_f16);
try test__powihf2(-math.inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f16);
try test__powihf2(-math.inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -math.inf_f16);
try test__powihf2(-inf_f16, 1, -inf_f16);
try test__powihf2(-inf_f16, 2, inf_f16);
try test__powihf2(-inf_f16, 3, -inf_f16);
try test__powihf2(-inf_f16, 4, inf_f16);
try test__powihf2(-inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f16);
try test__powihf2(-inf_f16, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -inf_f16);
//
try test__powihf2(0, -1, math.inf_f16);
try test__powihf2(0, -2, math.inf_f16);
try test__powihf2(0, -3, math.inf_f16);
try test__powihf2(0, -4, math.inf_f16);
try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f16); // 0 ^ anything = +inf
try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000001)), math.inf_f16);
try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f16);
try test__powihf2(0, -1, inf_f16);
try test__powihf2(0, -2, inf_f16);
try test__powihf2(0, -3, inf_f16);
try test__powihf2(0, -4, inf_f16);
try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000002)), inf_f16); // 0 ^ anything = +inf
try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000001)), inf_f16);
try test__powihf2(0, @bitCast(i32, @as(u32, 0x80000000)), inf_f16);
try test__powihf2(-0.0, -1, -math.inf_f16);
try test__powihf2(-0.0, -2, math.inf_f16);
try test__powihf2(-0.0, -3, -math.inf_f16);
try test__powihf2(-0.0, -4, math.inf_f16);
try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f16); // -0 ^ anything even = +inf
try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -math.inf_f16); // -0 ^ anything odd = -inf
try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f16);
try test__powihf2(-0.0, -1, -inf_f16);
try test__powihf2(-0.0, -2, inf_f16);
try test__powihf2(-0.0, -3, -inf_f16);
try test__powihf2(-0.0, -4, inf_f16);
try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), inf_f16); // -0 ^ anything even = +inf
try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -inf_f16); // -0 ^ anything odd = -inf
try test__powihf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), inf_f16);
try test__powihf2(1, -1, 1);
try test__powihf2(1, -2, 1);
@ -103,21 +104,21 @@ test "powihf2" {
try test__powihf2(1, @bitCast(i32, @as(u32, 0x80000001)), 1);
try test__powihf2(1, @bitCast(i32, @as(u32, 0x80000000)), 1);
try test__powihf2(math.inf_f16, -1, 0);
try test__powihf2(math.inf_f16, -2, 0);
try test__powihf2(math.inf_f16, -3, 0);
try test__powihf2(math.inf_f16, -4, 0);
try test__powihf2(math.inf_f16, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powihf2(math.inf_f16, @bitCast(i32, @as(u32, 0x80000001)), 0);
try test__powihf2(math.inf_f16, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powihf2(inf_f16, -1, 0);
try test__powihf2(inf_f16, -2, 0);
try test__powihf2(inf_f16, -3, 0);
try test__powihf2(inf_f16, -4, 0);
try test__powihf2(inf_f16, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powihf2(inf_f16, @bitCast(i32, @as(u32, 0x80000001)), 0);
try test__powihf2(inf_f16, @bitCast(i32, @as(u32, 0x80000000)), 0);
//
try test__powihf2(-math.inf_f16, -1, -0.0);
try test__powihf2(-math.inf_f16, -2, 0);
try test__powihf2(-math.inf_f16, -3, -0.0);
try test__powihf2(-math.inf_f16, -4, 0);
try test__powihf2(-math.inf_f16, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powihf2(-math.inf_f16, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
try test__powihf2(-math.inf_f16, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powihf2(-inf_f16, -1, -0.0);
try test__powihf2(-inf_f16, -2, 0);
try test__powihf2(-inf_f16, -3, -0.0);
try test__powihf2(-inf_f16, -4, 0);
try test__powihf2(-inf_f16, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powihf2(-inf_f16, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
try test__powihf2(-inf_f16, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powihf2(2, 10, 1024.0);
try test__powihf2(-2, 10, 1024.0);
@ -128,8 +129,8 @@ test "powihf2" {
try test__powihf2(-2, 14, 16384.0);
try test__powihf2(2, 15, 32768.0);
try test__powihf2(-2, 15, -32768.0);
try test__powihf2(2, 16, math.inf_f16);
try test__powihf2(-2, 16, math.inf_f16);
try test__powihf2(2, 16, inf_f16);
try test__powihf2(-2, 16, inf_f16);
try test__powihf2(2, -13, 1.0 / 8192.0);
try test__powihf2(-2, -13, -1.0 / 8192.0);
@ -140,17 +141,18 @@ test "powihf2" {
}
test "powisf2" {
const inf_f32 = math.inf(f32);
try test__powisf2(0, 0, 1);
try test__powisf2(1, 0, 1);
try test__powisf2(1.5, 0, 1);
try test__powisf2(2, 0, 1);
try test__powisf2(math.inf_f32, 0, 1);
try test__powisf2(inf_f32, 0, 1);
try test__powisf2(-0.0, 0, 1);
try test__powisf2(-1, 0, 1);
try test__powisf2(-1.5, 0, 1);
try test__powisf2(-2, 0, 1);
try test__powisf2(-math.inf_f32, 0, 1);
try test__powisf2(-inf_f32, 0, 1);
try test__powisf2(0, 1, 0);
try test__powisf2(0, 2, 0);
@ -173,35 +175,35 @@ test "powisf2" {
try test__powisf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFE)), 1);
try test__powisf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFF)), 1);
try test__powisf2(math.inf_f32, 1, math.inf_f32);
try test__powisf2(math.inf_f32, 2, math.inf_f32);
try test__powisf2(math.inf_f32, 3, math.inf_f32);
try test__powisf2(math.inf_f32, 4, math.inf_f32);
try test__powisf2(math.inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f32);
try test__powisf2(math.inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFF)), math.inf_f32);
try test__powisf2(inf_f32, 1, inf_f32);
try test__powisf2(inf_f32, 2, inf_f32);
try test__powisf2(inf_f32, 3, inf_f32);
try test__powisf2(inf_f32, 4, inf_f32);
try test__powisf2(inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f32);
try test__powisf2(inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFF)), inf_f32);
try test__powisf2(-math.inf_f32, 1, -math.inf_f32);
try test__powisf2(-math.inf_f32, 2, math.inf_f32);
try test__powisf2(-math.inf_f32, 3, -math.inf_f32);
try test__powisf2(-math.inf_f32, 4, math.inf_f32);
try test__powisf2(-math.inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f32);
try test__powisf2(-math.inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -math.inf_f32);
try test__powisf2(-inf_f32, 1, -inf_f32);
try test__powisf2(-inf_f32, 2, inf_f32);
try test__powisf2(-inf_f32, 3, -inf_f32);
try test__powisf2(-inf_f32, 4, inf_f32);
try test__powisf2(-inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f32);
try test__powisf2(-inf_f32, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -inf_f32);
try test__powisf2(0, -1, math.inf_f32);
try test__powisf2(0, -2, math.inf_f32);
try test__powisf2(0, -3, math.inf_f32);
try test__powisf2(0, -4, math.inf_f32);
try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f32);
try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000001)), math.inf_f32);
try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f32);
try test__powisf2(0, -1, inf_f32);
try test__powisf2(0, -2, inf_f32);
try test__powisf2(0, -3, inf_f32);
try test__powisf2(0, -4, inf_f32);
try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000002)), inf_f32);
try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000001)), inf_f32);
try test__powisf2(0, @bitCast(i32, @as(u32, 0x80000000)), inf_f32);
try test__powisf2(-0.0, -1, -math.inf_f32);
try test__powisf2(-0.0, -2, math.inf_f32);
try test__powisf2(-0.0, -3, -math.inf_f32);
try test__powisf2(-0.0, -4, math.inf_f32);
try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f32);
try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -math.inf_f32);
try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f32);
try test__powisf2(-0.0, -1, -inf_f32);
try test__powisf2(-0.0, -2, inf_f32);
try test__powisf2(-0.0, -3, -inf_f32);
try test__powisf2(-0.0, -4, inf_f32);
try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), inf_f32);
try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -inf_f32);
try test__powisf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), inf_f32);
try test__powisf2(1, -1, 1);
try test__powisf2(1, -2, 1);
@ -211,21 +213,21 @@ test "powisf2" {
try test__powisf2(1, @bitCast(i32, @as(u32, 0x80000001)), 1);
try test__powisf2(1, @bitCast(i32, @as(u32, 0x80000000)), 1);
try test__powisf2(math.inf_f32, -1, 0);
try test__powisf2(math.inf_f32, -2, 0);
try test__powisf2(math.inf_f32, -3, 0);
try test__powisf2(math.inf_f32, -4, 0);
try test__powisf2(math.inf_f32, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powisf2(math.inf_f32, @bitCast(i32, @as(u32, 0x80000001)), 0);
try test__powisf2(math.inf_f32, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powisf2(inf_f32, -1, 0);
try test__powisf2(inf_f32, -2, 0);
try test__powisf2(inf_f32, -3, 0);
try test__powisf2(inf_f32, -4, 0);
try test__powisf2(inf_f32, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powisf2(inf_f32, @bitCast(i32, @as(u32, 0x80000001)), 0);
try test__powisf2(inf_f32, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powisf2(-math.inf_f32, -1, -0.0);
try test__powisf2(-math.inf_f32, -2, 0);
try test__powisf2(-math.inf_f32, -3, -0.0);
try test__powisf2(-math.inf_f32, -4, 0);
try test__powisf2(-math.inf_f32, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powisf2(-math.inf_f32, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
try test__powisf2(-math.inf_f32, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powisf2(-inf_f32, -1, -0.0);
try test__powisf2(-inf_f32, -2, 0);
try test__powisf2(-inf_f32, -3, -0.0);
try test__powisf2(-inf_f32, -4, 0);
try test__powisf2(-inf_f32, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powisf2(-inf_f32, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
try test__powisf2(-inf_f32, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powisf2(2.0, 10, 1024.0);
try test__powisf2(-2, 10, 1024.0);
@ -244,17 +246,18 @@ test "powisf2" {
}
test "powidf2" {
const inf_f64 = math.inf(f64);
try test__powidf2(0, 0, 1);
try test__powidf2(1, 0, 1);
try test__powidf2(1.5, 0, 1);
try test__powidf2(2, 0, 1);
try test__powidf2(math.inf_f64, 0, 1);
try test__powidf2(inf_f64, 0, 1);
try test__powidf2(-0.0, 0, 1);
try test__powidf2(-1, 0, 1);
try test__powidf2(-1.5, 0, 1);
try test__powidf2(-2, 0, 1);
try test__powidf2(-math.inf_f64, 0, 1);
try test__powidf2(-inf_f64, 0, 1);
try test__powidf2(0, 1, 0);
try test__powidf2(0, 2, 0);
@ -277,35 +280,35 @@ test "powidf2" {
try test__powidf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFE)), 1);
try test__powidf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFF)), 1);
try test__powidf2(math.inf_f64, 1, math.inf_f64);
try test__powidf2(math.inf_f64, 2, math.inf_f64);
try test__powidf2(math.inf_f64, 3, math.inf_f64);
try test__powidf2(math.inf_f64, 4, math.inf_f64);
try test__powidf2(math.inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f64);
try test__powidf2(math.inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFF)), math.inf_f64);
try test__powidf2(inf_f64, 1, inf_f64);
try test__powidf2(inf_f64, 2, inf_f64);
try test__powidf2(inf_f64, 3, inf_f64);
try test__powidf2(inf_f64, 4, inf_f64);
try test__powidf2(inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f64);
try test__powidf2(inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFF)), inf_f64);
try test__powidf2(-math.inf_f64, 1, -math.inf_f64);
try test__powidf2(-math.inf_f64, 2, math.inf_f64);
try test__powidf2(-math.inf_f64, 3, -math.inf_f64);
try test__powidf2(-math.inf_f64, 4, math.inf_f64);
try test__powidf2(-math.inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f64);
try test__powidf2(-math.inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -math.inf_f64);
try test__powidf2(-inf_f64, 1, -inf_f64);
try test__powidf2(-inf_f64, 2, inf_f64);
try test__powidf2(-inf_f64, 3, -inf_f64);
try test__powidf2(-inf_f64, 4, inf_f64);
try test__powidf2(-inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f64);
try test__powidf2(-inf_f64, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -inf_f64);
try test__powidf2(0, -1, math.inf_f64);
try test__powidf2(0, -2, math.inf_f64);
try test__powidf2(0, -3, math.inf_f64);
try test__powidf2(0, -4, math.inf_f64);
try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f64);
try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000001)), math.inf_f64);
try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f64);
try test__powidf2(0, -1, inf_f64);
try test__powidf2(0, -2, inf_f64);
try test__powidf2(0, -3, inf_f64);
try test__powidf2(0, -4, inf_f64);
try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000002)), inf_f64);
try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000001)), inf_f64);
try test__powidf2(0, @bitCast(i32, @as(u32, 0x80000000)), inf_f64);
try test__powidf2(-0.0, -1, -math.inf_f64);
try test__powidf2(-0.0, -2, math.inf_f64);
try test__powidf2(-0.0, -3, -math.inf_f64);
try test__powidf2(-0.0, -4, math.inf_f64);
try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f64);
try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -math.inf_f64);
try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f64);
try test__powidf2(-0.0, -1, -inf_f64);
try test__powidf2(-0.0, -2, inf_f64);
try test__powidf2(-0.0, -3, -inf_f64);
try test__powidf2(-0.0, -4, inf_f64);
try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), inf_f64);
try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -inf_f64);
try test__powidf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), inf_f64);
try test__powidf2(1, -1, 1);
try test__powidf2(1, -2, 1);
@ -315,21 +318,21 @@ test "powidf2" {
try test__powidf2(1, @bitCast(i32, @as(u32, 0x80000001)), 1);
try test__powidf2(1, @bitCast(i32, @as(u32, 0x80000000)), 1);
try test__powidf2(math.inf_f64, -1, 0);
try test__powidf2(math.inf_f64, -2, 0);
try test__powidf2(math.inf_f64, -3, 0);
try test__powidf2(math.inf_f64, -4, 0);
try test__powidf2(math.inf_f64, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powidf2(math.inf_f64, @bitCast(i32, @as(u32, 0x80000001)), 0);
try test__powidf2(math.inf_f64, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powidf2(inf_f64, -1, 0);
try test__powidf2(inf_f64, -2, 0);
try test__powidf2(inf_f64, -3, 0);
try test__powidf2(inf_f64, -4, 0);
try test__powidf2(inf_f64, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powidf2(inf_f64, @bitCast(i32, @as(u32, 0x80000001)), 0);
try test__powidf2(inf_f64, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powidf2(-math.inf_f64, -1, -0.0);
try test__powidf2(-math.inf_f64, -2, 0);
try test__powidf2(-math.inf_f64, -3, -0.0);
try test__powidf2(-math.inf_f64, -4, 0);
try test__powidf2(-math.inf_f64, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powidf2(-math.inf_f64, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
try test__powidf2(-math.inf_f64, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powidf2(-inf_f64, -1, -0.0);
try test__powidf2(-inf_f64, -2, 0);
try test__powidf2(-inf_f64, -3, -0.0);
try test__powidf2(-inf_f64, -4, 0);
try test__powidf2(-inf_f64, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powidf2(-inf_f64, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
try test__powidf2(-inf_f64, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powidf2(2, 10, 1024.0);
try test__powidf2(-2, 10, 1024.0);
@ -348,17 +351,18 @@ test "powidf2" {
}
test "powitf2" {
const inf_f128 = math.inf(f128);
try test__powitf2(0, 0, 1);
try test__powitf2(1, 0, 1);
try test__powitf2(1.5, 0, 1);
try test__powitf2(2, 0, 1);
try test__powitf2(math.inf_f128, 0, 1);
try test__powitf2(inf_f128, 0, 1);
try test__powitf2(-0.0, 0, 1);
try test__powitf2(-1, 0, 1);
try test__powitf2(-1.5, 0, 1);
try test__powitf2(-2, 0, 1);
try test__powitf2(-math.inf_f128, 0, 1);
try test__powitf2(-inf_f128, 0, 1);
try test__powitf2(0, 1, 0);
try test__powitf2(0, 2, 0);
@ -381,35 +385,35 @@ test "powitf2" {
try test__powitf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFE)), 1);
try test__powitf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFF)), 1);
try test__powitf2(math.inf_f128, 1, math.inf_f128);
try test__powitf2(math.inf_f128, 2, math.inf_f128);
try test__powitf2(math.inf_f128, 3, math.inf_f128);
try test__powitf2(math.inf_f128, 4, math.inf_f128);
try test__powitf2(math.inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f128);
try test__powitf2(math.inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFF)), math.inf_f128);
try test__powitf2(inf_f128, 1, inf_f128);
try test__powitf2(inf_f128, 2, inf_f128);
try test__powitf2(inf_f128, 3, inf_f128);
try test__powitf2(inf_f128, 4, inf_f128);
try test__powitf2(inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f128);
try test__powitf2(inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFF)), inf_f128);
try test__powitf2(-math.inf_f128, 1, -math.inf_f128);
try test__powitf2(-math.inf_f128, 2, math.inf_f128);
try test__powitf2(-math.inf_f128, 3, -math.inf_f128);
try test__powitf2(-math.inf_f128, 4, math.inf_f128);
try test__powitf2(-math.inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f128);
try test__powitf2(-math.inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -math.inf_f128);
try test__powitf2(-inf_f128, 1, -inf_f128);
try test__powitf2(-inf_f128, 2, inf_f128);
try test__powitf2(-inf_f128, 3, -inf_f128);
try test__powitf2(-inf_f128, 4, inf_f128);
try test__powitf2(-inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f128);
try test__powitf2(-inf_f128, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -inf_f128);
try test__powitf2(0, -1, math.inf_f128);
try test__powitf2(0, -2, math.inf_f128);
try test__powitf2(0, -3, math.inf_f128);
try test__powitf2(0, -4, math.inf_f128);
try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f128);
try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000001)), math.inf_f128);
try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f128);
try test__powitf2(0, -1, inf_f128);
try test__powitf2(0, -2, inf_f128);
try test__powitf2(0, -3, inf_f128);
try test__powitf2(0, -4, inf_f128);
try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000002)), inf_f128);
try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000001)), inf_f128);
try test__powitf2(0, @bitCast(i32, @as(u32, 0x80000000)), inf_f128);
try test__powitf2(-0.0, -1, -math.inf_f128);
try test__powitf2(-0.0, -2, math.inf_f128);
try test__powitf2(-0.0, -3, -math.inf_f128);
try test__powitf2(-0.0, -4, math.inf_f128);
try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f128);
try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -math.inf_f128);
try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f128);
try test__powitf2(-0.0, -1, -inf_f128);
try test__powitf2(-0.0, -2, inf_f128);
try test__powitf2(-0.0, -3, -inf_f128);
try test__powitf2(-0.0, -4, inf_f128);
try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), inf_f128);
try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -inf_f128);
try test__powitf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), inf_f128);
try test__powitf2(1, -1, 1);
try test__powitf2(1, -2, 1);
@ -419,21 +423,21 @@ test "powitf2" {
try test__powitf2(1, @bitCast(i32, @as(u32, 0x80000001)), 1);
try test__powitf2(1, @bitCast(i32, @as(u32, 0x80000000)), 1);
try test__powitf2(math.inf_f128, -1, 0);
try test__powitf2(math.inf_f128, -2, 0);
try test__powitf2(math.inf_f128, -3, 0);
try test__powitf2(math.inf_f128, -4, 0);
try test__powitf2(math.inf_f128, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powitf2(math.inf_f128, @bitCast(i32, @as(u32, 0x80000001)), 0);
try test__powitf2(math.inf_f128, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powitf2(inf_f128, -1, 0);
try test__powitf2(inf_f128, -2, 0);
try test__powitf2(inf_f128, -3, 0);
try test__powitf2(inf_f128, -4, 0);
try test__powitf2(inf_f128, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powitf2(inf_f128, @bitCast(i32, @as(u32, 0x80000001)), 0);
try test__powitf2(inf_f128, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powitf2(-math.inf_f128, -1, -0.0);
try test__powitf2(-math.inf_f128, -2, 0);
try test__powitf2(-math.inf_f128, -3, -0.0);
try test__powitf2(-math.inf_f128, -4, 0);
try test__powitf2(-math.inf_f128, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powitf2(-math.inf_f128, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
try test__powitf2(-math.inf_f128, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powitf2(-inf_f128, -1, -0.0);
try test__powitf2(-inf_f128, -2, 0);
try test__powitf2(-inf_f128, -3, -0.0);
try test__powitf2(-inf_f128, -4, 0);
try test__powitf2(-inf_f128, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powitf2(-inf_f128, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
try test__powitf2(-inf_f128, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powitf2(2, 10, 1024.0);
try test__powitf2(-2, 10, 1024.0);
@ -452,17 +456,18 @@ test "powitf2" {
}
test "powixf2" {
const inf_f80 = math.inf(f80);
try test__powixf2(0, 0, 1);
try test__powixf2(1, 0, 1);
try test__powixf2(1.5, 0, 1);
try test__powixf2(2, 0, 1);
try test__powixf2(math.inf_f80, 0, 1);
try test__powixf2(inf_f80, 0, 1);
try test__powixf2(-0.0, 0, 1);
try test__powixf2(-1, 0, 1);
try test__powixf2(-1.5, 0, 1);
try test__powixf2(-2, 0, 1);
try test__powixf2(-math.inf_f80, 0, 1);
try test__powixf2(-inf_f80, 0, 1);
try test__powixf2(0, 1, 0);
try test__powixf2(0, 2, 0);
@ -485,35 +490,35 @@ test "powixf2" {
try test__powixf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFE)), 1);
try test__powixf2(1, @bitCast(i32, @as(u32, 0x7FFFFFFF)), 1);
try test__powixf2(math.inf_f80, 1, math.inf_f80);
try test__powixf2(math.inf_f80, 2, math.inf_f80);
try test__powixf2(math.inf_f80, 3, math.inf_f80);
try test__powixf2(math.inf_f80, 4, math.inf_f80);
try test__powixf2(math.inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f80);
try test__powixf2(math.inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFF)), math.inf_f80);
try test__powixf2(inf_f80, 1, inf_f80);
try test__powixf2(inf_f80, 2, inf_f80);
try test__powixf2(inf_f80, 3, inf_f80);
try test__powixf2(inf_f80, 4, inf_f80);
try test__powixf2(inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f80);
try test__powixf2(inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFF)), inf_f80);
try test__powixf2(-math.inf_f80, 1, -math.inf_f80);
try test__powixf2(-math.inf_f80, 2, math.inf_f80);
try test__powixf2(-math.inf_f80, 3, -math.inf_f80);
try test__powixf2(-math.inf_f80, 4, math.inf_f80);
try test__powixf2(-math.inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFE)), math.inf_f80);
try test__powixf2(-math.inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -math.inf_f80);
try test__powixf2(-inf_f80, 1, -inf_f80);
try test__powixf2(-inf_f80, 2, inf_f80);
try test__powixf2(-inf_f80, 3, -inf_f80);
try test__powixf2(-inf_f80, 4, inf_f80);
try test__powixf2(-inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFE)), inf_f80);
try test__powixf2(-inf_f80, @bitCast(i32, @as(u32, 0x7FFFFFFF)), -inf_f80);
try test__powixf2(0, -1, math.inf_f80);
try test__powixf2(0, -2, math.inf_f80);
try test__powixf2(0, -3, math.inf_f80);
try test__powixf2(0, -4, math.inf_f80);
try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f80);
try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000001)), math.inf_f80);
try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f80);
try test__powixf2(0, -1, inf_f80);
try test__powixf2(0, -2, inf_f80);
try test__powixf2(0, -3, inf_f80);
try test__powixf2(0, -4, inf_f80);
try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000002)), inf_f80);
try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000001)), inf_f80);
try test__powixf2(0, @bitCast(i32, @as(u32, 0x80000000)), inf_f80);
try test__powixf2(-0.0, -1, -math.inf_f80);
try test__powixf2(-0.0, -2, math.inf_f80);
try test__powixf2(-0.0, -3, -math.inf_f80);
try test__powixf2(-0.0, -4, math.inf_f80);
try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), math.inf_f80);
try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -math.inf_f80);
try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), math.inf_f80);
try test__powixf2(-0.0, -1, -inf_f80);
try test__powixf2(-0.0, -2, inf_f80);
try test__powixf2(-0.0, -3, -inf_f80);
try test__powixf2(-0.0, -4, inf_f80);
try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000002)), inf_f80);
try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000001)), -inf_f80);
try test__powixf2(-0.0, @bitCast(i32, @as(u32, 0x80000000)), inf_f80);
try test__powixf2(1, -1, 1);
try test__powixf2(1, -2, 1);
@ -523,21 +528,21 @@ test "powixf2" {
try test__powixf2(1, @bitCast(i32, @as(u32, 0x80000001)), 1);
try test__powixf2(1, @bitCast(i32, @as(u32, 0x80000000)), 1);
try test__powixf2(math.inf_f80, -1, 0);
try test__powixf2(math.inf_f80, -2, 0);
try test__powixf2(math.inf_f80, -3, 0);
try test__powixf2(math.inf_f80, -4, 0);
try test__powixf2(math.inf_f80, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powixf2(math.inf_f80, @bitCast(i32, @as(u32, 0x80000001)), 0);
try test__powixf2(math.inf_f80, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powixf2(inf_f80, -1, 0);
try test__powixf2(inf_f80, -2, 0);
try test__powixf2(inf_f80, -3, 0);
try test__powixf2(inf_f80, -4, 0);
try test__powixf2(inf_f80, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powixf2(inf_f80, @bitCast(i32, @as(u32, 0x80000001)), 0);
try test__powixf2(inf_f80, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powixf2(-math.inf_f80, -1, -0.0);
try test__powixf2(-math.inf_f80, -2, 0);
try test__powixf2(-math.inf_f80, -3, -0.0);
try test__powixf2(-math.inf_f80, -4, 0);
try test__powixf2(-math.inf_f80, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powixf2(-math.inf_f80, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
try test__powixf2(-math.inf_f80, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powixf2(-inf_f80, -1, -0.0);
try test__powixf2(-inf_f80, -2, 0);
try test__powixf2(-inf_f80, -3, -0.0);
try test__powixf2(-inf_f80, -4, 0);
try test__powixf2(-inf_f80, @bitCast(i32, @as(u32, 0x80000002)), 0);
try test__powixf2(-inf_f80, @bitCast(i32, @as(u32, 0x80000001)), -0.0);
try test__powixf2(-inf_f80, @bitCast(i32, @as(u32, 0x80000000)), 0);
try test__powixf2(2, 10, 1024.0);
try test__powixf2(-2, 10, 1024.0);

View File

@ -48,43 +48,41 @@ pub const floatMax = @import("math/float.zig").floatMax;
pub const floatEps = @import("math/float.zig").floatEps;
pub const inf = @import("math/float.zig").inf;
// TODO Replace with @compileError("deprecated for foobar") after 0.10.0 is released.
pub const f16_true_min: comptime_float = floatTrueMin(f16); // prev: 0.000000059604644775390625
pub const f32_true_min: comptime_float = floatTrueMin(f32); // prev: 1.40129846432481707092e-45
pub const f64_true_min: comptime_float = floatTrueMin(f64); // prev: 4.94065645841246544177e-324
pub const f80_true_min = floatTrueMin(f80); // prev: make_f80(.{ .fraction = 1, .exp = 0 })
pub const f128_true_min = floatTrueMin(f128); // prev: @bitCast(f128, @as(u128, 0x00000000000000000000000000000001))
pub const f16_min: comptime_float = floatMin(f16); // prev: 0.00006103515625
pub const f32_min: comptime_float = floatMin(f32); // prev: 1.17549435082228750797e-38
pub const f64_min: comptime_float = floatMin(f64); // prev: 2.2250738585072014e-308
pub const f80_min = floatMin(f80); // prev: make_f80(.{ .fraction = 0x8000000000000000, .exp = 1 })
pub const f128_min = floatMin(f128); // prev: @bitCast(f128, @as(u128, 0x00010000000000000000000000000000))
pub const f16_max: comptime_float = floatMax(f16); // prev: 65504
pub const f32_max: comptime_float = floatMax(f32); // prev: 3.40282346638528859812e+38
pub const f64_max: comptime_float = floatMax(f64); // prev: 1.79769313486231570815e+308
pub const f80_max = floatMax(f80); // prev: make_f80(.{ .fraction = 0xFFFFFFFFFFFFFFFF, .exp = 0x7FFE })
pub const f128_max = floatMax(f128); // prev: @bitCast(f128, @as(u128, 0x7FFEFFFFFFFFFFFFFFFFFFFFFFFFFFFF))
pub const f16_epsilon: comptime_float = floatEps(f16); // prev: 0.0009765625
pub const f32_epsilon: comptime_float = floatEps(f32); // prev: 1.1920928955078125e-07
pub const f64_epsilon: comptime_float = floatEps(f64); // prev: 2.22044604925031308085e-16
pub const f80_epsilon = floatEps(f80); // prev: make_f80(.{ .fraction = 0x8000000000000000, .exp = 0x3FC0 })
pub const f128_epsilon = floatEps(f128); // prev: @bitCast(f128, @as(u128, 0x3F8F0000000000000000000000000000))
pub const f16_toint: comptime_float = 1.0 / f16_epsilon; // same as before
pub const f32_toint: comptime_float = 1.0 / f32_epsilon; // same as before
pub const f64_toint: comptime_float = 1.0 / f64_epsilon; // same as before
pub const f80_toint = 1.0 / f80_epsilon; // same as before
pub const f128_toint = 1.0 / f128_epsilon; // same as before
pub const inf_u16 = @bitCast(u16, inf_f16); // prev: @as(u16, 0x7C00)
pub const inf_f16 = inf(f16); // prev: @bitCast(f16, inf_u16)
pub const inf_u32 = @bitCast(u32, inf_f32); // prev: @as(u32, 0x7F800000)
pub const inf_f32 = inf(f32); // prev: @bitCast(f32, inf_u32)
pub const inf_u64 = @bitCast(u64, inf_f64); // prev: @as(u64, 0x7FF << 52)
pub const inf_f64 = inf(f64); // prev: @bitCast(f64, inf_u64)
pub const inf_f80 = inf(f80); // prev: make_f80(F80{ .fraction = 0x8000000000000000, .exp = 0x7fff })
pub const inf_u128 = @bitCast(u128, inf_f128); // prev: @as(u128, 0x7fff0000000000000000000000000000)
pub const inf_f128 = inf(f128); // prev: @bitCast(f128, inf_u128)
pub const epsilon = floatEps;
// End of "soft deprecated" section
pub const f16_true_min = @compileError("Deprecated: use `floatTrueMin(f16)` instead");
pub const f32_true_min = @compileError("Deprecated: use `floatTrueMin(f32)` instead");
pub const f64_true_min = @compileError("Deprecated: use `floatTrueMin(f64)` instead");
pub const f80_true_min = @compileError("Deprecated: use `floatTrueMin(f80)` instead");
pub const f128_true_min = @compileError("Deprecated: use `floatTrueMin(f128)` instead");
pub const f16_min = @compileError("Deprecated: use `floatMin(f16)` instead");
pub const f32_min = @compileError("Deprecated: use `floatMin(f32)` instead");
pub const f64_min = @compileError("Deprecated: use `floatMin(f64)` instead");
pub const f80_min = @compileError("Deprecated: use `floatMin(f80)` instead");
pub const f128_min = @compileError("Deprecated: use `floatMin(f128)` instead");
pub const f16_max = @compileError("Deprecated: use `floatMax(f16)` instead");
pub const f32_max = @compileError("Deprecated: use `floatMax(f32)` instead");
pub const f64_max = @compileError("Deprecated: use `floatMax(f64)` instead");
pub const f80_max = @compileError("Deprecated: use `floatMax(f80)` instead");
pub const f128_max = @compileError("Deprecated: use `floatMax(f128)` instead");
pub const f16_epsilon = @compileError("Deprecated: use `floatEps(f16)` instead");
pub const f32_epsilon = @compileError("Deprecated: use `floatEps(f32)` instead");
pub const f64_epsilon = @compileError("Deprecated: use `floatEps(f64)` instead");
pub const f80_epsilon = @compileError("Deprecated: use `floatEps(f80)` instead");
pub const f128_epsilon = @compileError("Deprecated: use `floatEps(f128)` instead");
pub const f16_toint = @compileError("Deprecated: use `1.0 / floatEps(f16)` instead");
pub const f32_toint = @compileError("Deprecated: use `1.0 / floatEps(f32)` instead");
pub const f64_toint = @compileError("Deprecated: use `1.0 / floatEps(f64)` instead");
pub const f80_toint = @compileError("Deprecated: use `1.0 / floatEps(f80)` instead");
pub const f128_toint = @compileError("Deprecated: use `1.0 / floatEps(f128)` instead");
pub const inf_u16 = @compileError("Deprecated: use `@bitCast(u16, inf(f16))` instead");
pub const inf_f16 = @compileError("Deprecated: use `inf(f16)` instead");
pub const inf_u32 = @compileError("Deprecated: use `@bitCast(u32, inf(f32))` instead");
pub const inf_f32 = @compileError("Deprecated: use `inf(f32)` instead");
pub const inf_u64 = @compileError("Deprecated: use `@bitCast(u64, inf(f64))` instead");
pub const inf_f64 = @compileError("Deprecated: use `inf(f64)` instead");
pub const inf_f80 = @compileError("Deprecated: use `inf(f80)` instead");
pub const inf_u128 = @compileError("Deprecated: use `@bitCast(u128, inf(f128))` instead");
pub const inf_f128 = @compileError("Deprecated: use `inf(f128)` instead");
pub const epsilon = @compileError("Deprecated: use `floatEps` instead");
pub const nan_u16 = @as(u16, 0x7C01);
pub const nan_f16 = @bitCast(f16, nan_u16);
@ -329,7 +327,92 @@ pub const Complex = complex.Complex;
pub const big = @import("math/big.zig");
test {
std.testing.refAllDecls(@This());
_ = floatExponentBits;
_ = floatMantissaBits;
_ = floatFractionalBits;
_ = floatExponentMin;
_ = floatExponentMax;
_ = floatTrueMin;
_ = floatMin;
_ = floatMax;
_ = floatEps;
_ = inf;
_ = nan_u16;
_ = nan_f16;
_ = qnan_u16;
_ = qnan_f16;
_ = nan_u32;
_ = nan_f32;
_ = qnan_u32;
_ = qnan_f32;
_ = nan_u64;
_ = nan_f64;
_ = qnan_u64;
_ = qnan_f64;
_ = nan_f80;
_ = qnan_f80;
_ = nan_u128;
_ = nan_f128;
_ = qnan_u128;
_ = qnan_f128;
_ = nan;
_ = snan;
_ = isNan;
_ = isSignalNan;
_ = frexp;
_ = Frexp;
_ = modf;
_ = modf32_result;
_ = modf64_result;
_ = copysign;
_ = isFinite;
_ = isInf;
_ = isPositiveInf;
_ = isNegativeInf;
_ = isNormal;
_ = signbit;
_ = scalbn;
_ = ldexp;
_ = pow;
_ = powi;
_ = sqrt;
_ = cbrt;
_ = acos;
_ = asin;
_ = atan;
_ = atan2;
_ = hypot;
_ = expm1;
_ = ilogb;
_ = ln;
_ = log;
_ = log2;
_ = log10;
_ = log10_int;
_ = log1p;
_ = asinh;
_ = acosh;
_ = atanh;
_ = sinh;
_ = cosh;
_ = tanh;
_ = gcd;
_ = complex;
_ = Complex;
_ = big;
}
/// Given two types, returns the smallest one which is capable of holding the

View File

@ -410,7 +410,7 @@ pub const Random = struct {
r.uintLessThan(T, sum)
else if (comptime std.meta.trait.isFloat(T))
// take care that imprecision doesn't lead to a value slightly greater than sum
std.math.min(r.float(T) * sum, sum - std.math.epsilon(T))
std.math.min(r.float(T) * sum, sum - std.math.floatEps(T))
else
@compileError("weightedIndex does not support proportions of type " ++ @typeName(T));

View File

@ -263,7 +263,7 @@ pub fn expectApproxEqRel(expected: anytype, actual: @TypeOf(expected), tolerance
test "expectApproxEqRel" {
inline for ([_]type{ f16, f32, f64, f128 }) |T| {
const eps_value = comptime math.epsilon(T);
const eps_value = comptime math.floatEps(T);
const sqrt_eps_value = comptime @sqrt(eps_value);
const pos_x: T = 12.0;

View File

@ -357,9 +357,9 @@ test "pointer sentinel with +inf" {
const S = struct {
fn doTheTest() !void {
const inf = std.math.inf_f32;
var ptr: [*:inf]const f32 = &[_:inf]f32{ 1.1, 2.2, 3.3, 4.4 };
try expect(ptr[4] == inf); // TODO this should be comptime try expect, see #3731
const inf_f32 = comptime std.math.inf(f32);
var ptr: [*:inf_f32]const f32 = &[_:inf_f32]f32{ 1.1, 2.2, 3.3, 4.4 };
try expect(ptr[4] == inf_f32); // TODO this should be comptime try expect, see #3731
}
};
try S.doTheTest();