mirror of
https://github.com/ziglang/zig.git
synced 2025-12-06 06:13:07 +00:00
parent
201c0f54a5
commit
cffa98eef5
@ -159,6 +159,9 @@ test "hex.special" {
|
|||||||
try testing.expect(math.isPositiveInf(try parseFloat(f32, "iNf")));
|
try testing.expect(math.isPositiveInf(try parseFloat(f32, "iNf")));
|
||||||
try testing.expect(math.isPositiveInf(try parseFloat(f32, "+Inf")));
|
try testing.expect(math.isPositiveInf(try parseFloat(f32, "+Inf")));
|
||||||
try testing.expect(math.isNegativeInf(try parseFloat(f32, "-iNf")));
|
try testing.expect(math.isNegativeInf(try parseFloat(f32, "-iNf")));
|
||||||
|
|
||||||
|
try testing.expect(math.isPositiveInf(try parseFloat(f32, "0x9999p9999")));
|
||||||
|
try testing.expect(math.isNegativeInf(try parseFloat(f32, "-0x9999p9999")));
|
||||||
}
|
}
|
||||||
|
|
||||||
test "hex.zero" {
|
test "hex.zero" {
|
||||||
|
|||||||
@ -78,7 +78,7 @@ pub fn convertHex(comptime T: type, n_: Number(T)) T {
|
|||||||
|
|
||||||
// Infinity and range error
|
// Infinity and range error
|
||||||
if (n.exponent > max_exp) {
|
if (n.exponent > max_exp) {
|
||||||
return math.inf(T);
|
return if (n.negative) -math.inf(T) else math.inf(T);
|
||||||
}
|
}
|
||||||
|
|
||||||
var bits = n.mantissa & ((1 << mantissa_bits) - 1);
|
var bits = n.mantissa & ((1 << mantissa_bits) - 1);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user