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

Tue Ly via Phabricator via libc-commits libc-commits at lists.llvm.org
Mon Nov 15 11:23:28 PST 2021

lntue added inline comments.

Comment at: libc/src/__support/str_to_float.h:522
+  *outputMantissa = mantissa & fputil::FloatProperties<T>::mantissaMask;
   *outputExp2 = biasedExponent;
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).   

  rG LLVM Github Monorepo



More information about the libc-commits mailing list