[libc-commits] [PATCH] D113815: [libc] Correct rounding for hexadecimalStringToFloat with long inputs.

Michael Jones via Phabricator via libc-commits libc-commits at lists.llvm.org
Tue Nov 16 10:44:39 PST 2021

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


Comment at: libc/src/__support/str_to_float.h:522
+  *outputMantissa = mantissa & fputil::FloatProperties<T>::mantissaMask;
   *outputExp2 = biasedExponent;
lntue wrote:
> michaelrj wrote:
> > This is unnecessary, since the FloatBits type will do it when setting the mantissa of the final value. It also doesn't really hurt anything to have it, but I generally prefer to get the full output bits for testing.
> I think it is better for maintainability and consistency to have the outputs well-defined (as is expected results bits in the answer) instead of relying on the caller to do the cleanup without being documented.   For instance, without this clean up, INF results might have outputMantissa == 0, 2^mantissaLength, or 2^(mantissaLength+1).   
That seems reasonable, in that case I should probably go fix the other functions to match, although that will require fixing a lot of tests.

  rG LLVM Github Monorepo



More information about the libc-commits mailing list