aboutsummaryrefslogtreecommitdiff
path: root/lib/std/math/isnormal.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-06-24 16:58:19 -0700
committerGitHub <noreply@github.com>2023-06-24 16:58:19 -0700
commit146b79af153bbd5dafda0ba12a040385c7fc58f8 (patch)
tree67e3db8b444d65c667e314770fc983a7fc8ba293 /lib/std/math/isnormal.zig
parent13853bef0df3c90633021850cc6d6abaeea03282 (diff)
parent21ac0beb436f49fe49c6982a872f2dc48e4bea5e (diff)
downloadzig-146b79af153bbd5dafda0ba12a040385c7fc58f8.tar.gz
zig-146b79af153bbd5dafda0ba12a040385c7fc58f8.zip
Merge pull request #16163 from mlugg/feat/builtins-infer-dest-ty
Infer destination type of cast builtins using result type
Diffstat (limited to 'lib/std/math/isnormal.zig')
-rw-r--r--lib/std/math/isnormal.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/std/math/isnormal.zig b/lib/std/math/isnormal.zig
index 08f848f5df..38b459b54e 100644
--- a/lib/std/math/isnormal.zig
+++ b/lib/std/math/isnormal.zig
@@ -15,7 +15,7 @@ pub fn isNormal(x: anytype) bool {
// The sign bit is removed because all ones would overflow into it.
// For f80, even though it has an explicit integer part stored,
// the exponent effectively takes priority if mismatching.
- const value = @bitCast(TBits, x) +% increment_exp;
+ const value = @as(TBits, @bitCast(x)) +% increment_exp;
return value & remove_sign >= (increment_exp << 1);
}
@@ -35,7 +35,7 @@ test "math.isNormal" {
try expect(!isNormal(@as(T, math.floatTrueMin(T))));
// largest subnormal
- try expect(!isNormal(@bitCast(T, ~(~@as(TBits, 0) << math.floatFractionalBits(T)))));
+ try expect(!isNormal(@as(T, @bitCast(~(~@as(TBits, 0) << math.floatFractionalBits(T))))));
// non-finite numbers
try expect(!isNormal(-math.inf(T)));
@@ -43,6 +43,6 @@ test "math.isNormal" {
try expect(!isNormal(math.nan(T)));
// overflow edge-case (described in implementation, also see #10133)
- try expect(!isNormal(@bitCast(T, ~@as(TBits, 0))));
+ try expect(!isNormal(@as(T, @bitCast(~@as(TBits, 0)))));
}
}