| author | |
| committer | |
| log | 951ab802a38ede9f5329aeae1fed00161321d558 |
| tree | b72445012f44c57c5e4670ebfc9e675777958fc4 |
| parent | 70b6b98e91fb9d1d5575da4d59c5c523864a8f0e |
| signature |
4 files changed, 4 insertions(+), 16 deletions(-)
lib/std/math/isfinite.zig+1-4| ... | ... | @@ -5,10 +5,7 @@ const expect = std.testing.expect; |
| 5 | 5 | /// Returns whether x is a finite value. |
| 6 | 6 | pub fn isFinite(x: anytype) bool { |
| 7 | 7 | const T = @TypeOf(x); |
| 8 | const TBits = std.meta.Int(.unsigned, @bitSizeOf(T)); | |
| 9 | if (@typeInfo(T) != .Float) { | |
| 10 | @compileError("isFinite not implemented for " ++ @typeName(T)); | |
| 11 | } | |
| 8 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 12 | 9 | const remove_sign = ~@as(TBits, 0) >> 1; |
| 13 | 10 | return @bitCast(TBits, x) & remove_sign < @bitCast(TBits, math.inf(T)); |
| 14 | 11 | } |
lib/std/math/isinf.zig+1-4| ... | ... | @@ -5,10 +5,7 @@ const expect = std.testing.expect; |
| 5 | 5 | /// Returns whether x is an infinity, ignoring sign. |
| 6 | 6 | pub fn isInf(x: anytype) bool { |
| 7 | 7 | const T = @TypeOf(x); |
| 8 | const TBits = std.meta.Int(.unsigned, @bitSizeOf(T)); | |
| 9 | if (@typeInfo(T) != .Float) { | |
| 10 | @compileError("isInf not implemented for " ++ @typeName(T)); | |
| 11 | } | |
| 8 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 12 | 9 | const remove_sign = ~@as(TBits, 0) >> 1; |
| 13 | 10 | return @bitCast(TBits, x) & remove_sign == @bitCast(TBits, math.inf(T)); |
| 14 | 11 | } |
lib/std/math/isnormal.zig+1-4| ... | ... | @@ -5,10 +5,7 @@ const expect = std.testing.expect; |
| 5 | 5 | /// Returns whether x is neither zero, subnormal, infinity, or NaN. |
| 6 | 6 | pub fn isNormal(x: anytype) bool { |
| 7 | 7 | const T = @TypeOf(x); |
| 8 | const TBits = std.meta.Int(.unsigned, @bitSizeOf(T)); | |
| 9 | if (@typeInfo(T) != .Float) { | |
| 10 | @compileError("isNormal not implemented for " ++ @typeName(T)); | |
| 11 | } | |
| 8 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 12 | 9 | |
| 13 | 10 | const increment_exp = 1 << math.floatMantissaBits(T); |
| 14 | 11 | const remove_sign = ~@as(TBits, 0) >> 1; |
lib/std/math/ldexp.zig+1-4| ... | ... | @@ -15,10 +15,7 @@ pub fn ldexp(x: anytype, n: i32) @TypeOf(x) { |
| 15 | 15 | var shift = n; |
| 16 | 16 | |
| 17 | 17 | const T = @TypeOf(base); |
| 18 | const TBits = std.meta.Int(.unsigned, @bitSizeOf(T)); | |
| 19 | if (@typeInfo(T) != .Float) { | |
| 20 | @compileError("ldexp not implemented for " ++ @typeName(T)); | |
| 21 | } | |
| 18 | const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); | |
| 22 | 19 | |
| 23 | 20 | const mantissa_bits = math.floatMantissaBits(T); |
| 24 | 21 | const exponent_min = math.floatExponentMin(T); |