diff --git a/lib/std/math/isfinite.zig b/lib/std/math/isfinite.zig index 67a67a4610..556f8a2378 100644 --- a/lib/std/math/isfinite.zig +++ b/lib/std/math/isfinite.zig @@ -5,10 +5,7 @@ const expect = std.testing.expect; /// Returns whether x is a finite value. pub fn isFinite(x: anytype) bool { const T = @TypeOf(x); - const TBits = std.meta.Int(.unsigned, @bitSizeOf(T)); - if (@typeInfo(T) != .Float) { - @compileError("isFinite not implemented for " ++ @typeName(T)); - } + const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); const remove_sign = ~@as(TBits, 0) >> 1; return @bitCast(TBits, x) & remove_sign < @bitCast(TBits, math.inf(T)); } diff --git a/lib/std/math/isinf.zig b/lib/std/math/isinf.zig index 7275740fcc..a26332411f 100644 --- a/lib/std/math/isinf.zig +++ b/lib/std/math/isinf.zig @@ -5,10 +5,7 @@ const expect = std.testing.expect; /// Returns whether x is an infinity, ignoring sign. pub fn isInf(x: anytype) bool { const T = @TypeOf(x); - const TBits = std.meta.Int(.unsigned, @bitSizeOf(T)); - if (@typeInfo(T) != .Float) { - @compileError("isInf not implemented for " ++ @typeName(T)); - } + const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); const remove_sign = ~@as(TBits, 0) >> 1; return @bitCast(TBits, x) & remove_sign == @bitCast(TBits, math.inf(T)); } diff --git a/lib/std/math/isnormal.zig b/lib/std/math/isnormal.zig index e15d8a91cc..08f848f5df 100644 --- a/lib/std/math/isnormal.zig +++ b/lib/std/math/isnormal.zig @@ -5,10 +5,7 @@ const expect = std.testing.expect; /// Returns whether x is neither zero, subnormal, infinity, or NaN. pub fn isNormal(x: anytype) bool { const T = @TypeOf(x); - const TBits = std.meta.Int(.unsigned, @bitSizeOf(T)); - if (@typeInfo(T) != .Float) { - @compileError("isNormal not implemented for " ++ @typeName(T)); - } + const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); const increment_exp = 1 << math.floatMantissaBits(T); const remove_sign = ~@as(TBits, 0) >> 1; diff --git a/lib/std/math/ldexp.zig b/lib/std/math/ldexp.zig index 0934244c65..57d8896c9c 100644 --- a/lib/std/math/ldexp.zig +++ b/lib/std/math/ldexp.zig @@ -15,10 +15,7 @@ pub fn ldexp(x: anytype, n: i32) @TypeOf(x) { var shift = n; const T = @TypeOf(base); - const TBits = std.meta.Int(.unsigned, @bitSizeOf(T)); - if (@typeInfo(T) != .Float) { - @compileError("ldexp not implemented for " ++ @typeName(T)); - } + const TBits = std.meta.Int(.unsigned, @typeInfo(T).Float.bits); const mantissa_bits = math.floatMantissaBits(T); const exponent_min = math.floatExponentMin(T);