From b837855317c3f73248e1ea4f3cad6b06d2568443 Mon Sep 17 00:00:00 2001 From: J87 <68929154+jake-87@users.noreply.github.com> Date: Fri, 18 Feb 2022 13:17:32 +1100 Subject: [PATCH] Replace magic numbers with clearer representation Replaces two magic numbers with the procedure used to generate them, in order to keep consistent with other implementations for f64 & f128. --- lib/std/math/fabs.zig | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/std/math/fabs.zig b/lib/std/math/fabs.zig index 1221db2390..f098d531cf 100644 --- a/lib/std/math/fabs.zig +++ b/lib/std/math/fabs.zig @@ -27,13 +27,13 @@ pub fn fabs(x: anytype) @TypeOf(x) { fn fabs16(x: f16) f16 { var u = @bitCast(u16, x); - u &= 0x7FFF; + u &= maxInt(u16) >> 1; return @bitCast(f16, u); } fn fabs32(x: f32) f32 { var u = @bitCast(u32, x); - u &= 0x7FFFFFFF; + u &= maxInt(u32) >> 1; return @bitCast(f32, u); }