Commit 8e0b2f0e52

LemonBoy <thatlemon@gmail.com>
2021-04-15 18:14:25
compiler-rt: Fix typo in implementation of fp truncation ops
The problem went unnoticed for years, yay.
1 parent f948140
Changed files (1)
lib
std
special
compiler_rt
lib/std/special/compiler_rt/truncXfYf2.zig
@@ -122,7 +122,7 @@ fn truncXfYf2(comptime dst_t: type, comptime src_t: type, a: src_t) dst_t {
         if (shift > srcSigBits) {
             absResult = 0;
         } else {
-            const sticky: src_rep_t = significand << @intCast(SrcShift, srcBits - shift);
+            const sticky: src_rep_t = @boolToInt(significand << @intCast(SrcShift, srcBits - shift) != 0);
             const denormalizedSignificand: src_rep_t = significand >> @intCast(SrcShift, shift) | sticky;
             absResult = @intCast(dst_rep_t, denormalizedSignificand >> (srcSigBits - dstSigBits));
             const roundBits: src_rep_t = denormalizedSignificand & roundMask;