[libc-commits] [PATCH] D136699: [libc] tighten strtofloat cutoffs
Siva Chandra via Phabricator via libc-commits
libc-commits at lists.llvm.org
Tue Oct 25 11:00:41 PDT 2022
sivachandra accepted this revision.
sivachandra added inline comments.
This revision is now accepted and ready to land.
================
Comment at: libc/src/__support/str_to_float.h:563
+// give a non-zero result for this size of float. The value is
+// log_10(2^(exponent bias + mantissa width + intermediate mantissa width))
+// The generic approximation uses the fact that log_10(2^x) ~= x/3
----------------
What is "intermediate mantissa width"?
================
Comment at: libc/src/__support/str_to_float.h:600
// If the exponent is too small even for a subnormal, return 0.
- if (exp10 < 0 &&
- -static_cast<int64_t>(exp10) >
- static_cast<int64_t>(fputil::FloatProperties<T>::EXPONENT_BIAS +
- fputil::FloatProperties<T>::MANTISSA_WIDTH) /
- 2) {
+ if (exp10 < 0 && -static_cast<int64_t>(exp10) > get_lower_bound<T>()) {
*outputMantissa = 0;
----------------
If you return a negative value from `get_lower_bound`, you don't have to do the inverted test, but simply:
```
if (exp10 < 0 && int64_t(exp) < get_lower_bound<T>()) {
...
}
```
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D136699/new/
https://reviews.llvm.org/D136699
More information about the libc-commits
mailing list