[libc-commits] [PATCH] D119156: [libc] Fix mixed-sign comparison warnings and an out-of-bound access in high_precision_decimal.h

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Feb 7 10:42:51 PST 2022


michaelrj accepted this revision.
michaelrj added a comment.
This revision is now accepted and ready to land.

LGTM



================
Comment at: libc/src/__support/high_precision_decimal.h:131
       // If this exactly halfway, round to even.
+      if (roundToDigit == 0)
+        // When the input is ".5".
----------------
lntue wrote:
> michaelrj wrote:
> > I think that instead of having this, you could change the condition at the start of the function from `roundToDigit < 0` to `roundToDigit <= 0`, and it would have a more useful effect. If we're requesting 0 digits, then it should always round down, even if it's truncated.
> Then it will return false for something that needs roundup like ".51".
ah, yes, I see what you mean, nevermind then.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119156/new/

https://reviews.llvm.org/D119156



More information about the libc-commits mailing list