[libc-commits] [PATCH] D118791: [libc][Obvious] Fix a mismatch signature of HighPrecisionDecimal::should_round_up.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Thu Feb 3 14:27:24 PST 2022

sivachandra added a comment.

In D118791#3295095 <https://reviews.llvm.org/D118791#3295095>, @michaelrj wrote:

> This is incorrect, should_round_up is called on `decimal_point` which is specifically signed because it represents the index of where the decimal point should be, relative to the digits. Specifically a negative decimal point represents a number that is less than 1. There is an if statement on line 115 to handle if roundToDigit is negative. While the code will still work if this change is made (any reasonable negative number will create an unsigned number greater than `this->num_digits`) it would make the code less correct.

Isn't your reason exactly why this change is required? For, if `roundToDigit` was unsigned, `roundToDigit < 0` will never be `true`?

  rG LLVM Github Monorepo



More information about the libc-commits mailing list