Add support for the %e/E conversion in printf, as well as unit tests. It
does not yet support long doubles.
Details
- Reviewers
sivachandra lntue - Commits
- rG51126518261a: [libc] add exponent format to printf
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Mostly LGTM with a question inline.
libc/src/stdio/printf_core/float_dec_converter.h | ||
---|---|---|
191 | Is -exponent guaranteed to not overflow here? If not, then may be you should just let IntegerToString handle the sign for negative numbers, but add a + if exponent is non-negative. |
libc/src/stdio/printf_core/float_dec_converter.h | ||
---|---|---|
191 | yes exponent is guaranteed not to overflow. It is an int (usually 32 bits, but a minimum of 16) and long doubles have a maximum of 15 bits for their exponent. |
libc/src/stdio/printf_core/float_dec_converter.h | ||
---|---|---|
191 | Ah, OK! It will be good to include a note with this information and a static assert to go with it. Some thing like: static_assert(FloatProperties<long double>::EXPONENT_WIDTH < sizeof(int)); |
Is -exponent guaranteed to not overflow here? If not, then may be you should just let IntegerToString handle the sign for negative numbers, but add a + if exponent is non-negative.