mirror of
https://github.com/ziglang/zig.git
synced 2026-02-21 16:54:52 +00:00
better f64_is_nan
This commit is contained in:
parent
90a32629c0
commit
850f6d2d02
@ -17,7 +17,11 @@ pub fn f64_get_neg_inf() -> f64 {
|
||||
}
|
||||
|
||||
pub fn f64_is_nan(f: f64) -> bool {
|
||||
0x7FFFFFFFFFFFFFFF == f64_to_bits(f) // TODO improve to catch all cases
|
||||
const bits = f64_to_bits(f);
|
||||
const exp: i64 = i64((bits >> 52) & ((1 << 11) - 1));
|
||||
const sig = (bits & ((1 << 52) - 1)) | (1 << 52);
|
||||
|
||||
sig != 0 && exp == (1 << 11) - 1
|
||||
}
|
||||
|
||||
pub fn f64_is_inf(f: f64) -> bool {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user