Update binaryExpTofloat so that it will round correctly for long inputs when converting hexadecimal strings to floating points.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libc/src/__support/str_to_float.h | ||
---|---|---|
522 | 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. | |
662–665 | setting seenDigit to false isn't recommended, since it should just be a flag for if any digit has been seen. This particular if would cause numbers that end with alphanumeric characters that aren't in base to return as zero, for example 0x1z. |
[libc] Correct rounding for hexadecimalStringToFloat with long inputs.
libc/src/__support/str_to_float.h | ||
---|---|---|
522 | 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). |
LGTM
libc/src/__support/str_to_float.h | ||
---|---|---|
522 | 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. |
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.