use math/float.zig everywhere

This commit is contained in:
viri
2022-04-06 20:49:05 -06:00
parent 5d6a5a1236
commit e46c612503
26 changed files with 177 additions and 173 deletions

View File

@@ -262,14 +262,14 @@ test "f16" {
.{ .s = "0x10p+10", .v = 16384.0 },
.{ .s = "0x10p-10", .v = 0.015625 },
// Max normalized value.
.{ .s = "0x1.ffcp+15", .v = math.f16_max },
.{ .s = "-0x1.ffcp+15", .v = -math.f16_max },
.{ .s = "0x1.ffcp+15", .v = math.floatMax(f16) },
.{ .s = "-0x1.ffcp+15", .v = -math.floatMax(f16) },
// Min normalized value.
.{ .s = "0x1p-14", .v = math.f16_min },
.{ .s = "-0x1p-14", .v = -math.f16_min },
.{ .s = "0x1p-14", .v = math.floatMin(f16) },
.{ .s = "-0x1p-14", .v = -math.floatMin(f16) },
// Min denormal value.
.{ .s = "0x1p-24", .v = math.f16_true_min },
.{ .s = "-0x1p-24", .v = -math.f16_true_min },
.{ .s = "0x1p-24", .v = math.floatTrueMin(f16) },
.{ .s = "-0x1p-24", .v = -math.floatTrueMin(f16) },
};
for (cases) |case| {
@@ -286,14 +286,14 @@ test "f32" {
.{ .s = "0x0.ffffffp128", .v = 0x0.ffffffp128 },
.{ .s = "0x0.1234570p-125", .v = 0x0.1234570p-125 },
// Max normalized value.
.{ .s = "0x1.fffffeP+127", .v = math.f32_max },
.{ .s = "-0x1.fffffeP+127", .v = -math.f32_max },
.{ .s = "0x1.fffffeP+127", .v = math.floatMax(f32) },
.{ .s = "-0x1.fffffeP+127", .v = -math.floatMax(f32) },
// Min normalized value.
.{ .s = "0x1p-126", .v = math.f32_min },
.{ .s = "-0x1p-126", .v = -math.f32_min },
.{ .s = "0x1p-126", .v = math.floatMin(f32) },
.{ .s = "-0x1p-126", .v = -math.floatMin(f32) },
// Min denormal value.
.{ .s = "0x1P-149", .v = math.f32_true_min },
.{ .s = "-0x1P-149", .v = -math.f32_true_min },
.{ .s = "0x1P-149", .v = math.floatTrueMin(f32) },
.{ .s = "-0x1P-149", .v = -math.floatTrueMin(f32) },
};
for (cases) |case| {
@@ -308,14 +308,14 @@ test "f64" {
.{ .s = "0x10p+10", .v = 16384.0 },
.{ .s = "0x10p-10", .v = 0.015625 },
// Max normalized value.
.{ .s = "0x1.fffffffffffffp+1023", .v = math.f64_max },
.{ .s = "-0x1.fffffffffffffp1023", .v = -math.f64_max },
.{ .s = "0x1.fffffffffffffp+1023", .v = math.floatMax(f64) },
.{ .s = "-0x1.fffffffffffffp1023", .v = -math.floatMax(f64) },
// Min normalized value.
.{ .s = "0x1p-1022", .v = math.f64_min },
.{ .s = "-0x1p-1022", .v = -math.f64_min },
.{ .s = "0x1p-1022", .v = math.floatMin(f64) },
.{ .s = "-0x1p-1022", .v = -math.floatMin(f64) },
// Min denormalized value.
.{ .s = "0x1p-1074", .v = math.f64_true_min },
.{ .s = "-0x1p-1074", .v = -math.f64_true_min },
.{ .s = "0x1p-1074", .v = math.floatTrueMin(f64) },
.{ .s = "-0x1p-1074", .v = -math.floatTrueMin(f64) },
};
for (cases) |case| {
@@ -330,14 +330,14 @@ test "f128" {
.{ .s = "0x10p+10", .v = 16384.0 },
.{ .s = "0x10p-10", .v = 0.015625 },
// Max normalized value.
.{ .s = "0xf.fffffffffffffffffffffffffff8p+16380", .v = math.f128_max },
.{ .s = "-0xf.fffffffffffffffffffffffffff8p+16380", .v = -math.f128_max },
.{ .s = "0xf.fffffffffffffffffffffffffff8p+16380", .v = math.floatMax(f128) },
.{ .s = "-0xf.fffffffffffffffffffffffffff8p+16380", .v = -math.floatMax(f128) },
// Min normalized value.
.{ .s = "0x1p-16382", .v = math.f128_min },
.{ .s = "-0x1p-16382", .v = -math.f128_min },
.{ .s = "0x1p-16382", .v = math.floatMin(f128) },
.{ .s = "-0x1p-16382", .v = -math.floatMin(f128) },
// // Min denormalized value.
.{ .s = "0x1p-16494", .v = math.f128_true_min },
.{ .s = "-0x1p-16494", .v = -math.f128_true_min },
.{ .s = "0x1p-16494", .v = math.floatTrueMin(f128) },
.{ .s = "-0x1p-16494", .v = -math.floatTrueMin(f128) },
.{ .s = "0x1.edcb34a235253948765432134674fp-1", .v = 0x1.edcb34a235253948765432134674fp-1 },
};