[libc] Fix printf %f rounding condition
authorMichael Jones <michaelrj@google.com>
Tue, 28 Feb 2023 23:10:08 +0000 (15:10 -0800)
committerMichael Jones <michaelrj@google.com>
Wed, 1 Mar 2023 18:57:26 +0000 (10:57 -0800)
commitb39f1e5c13897b69c314febd014895a5ed23696e
tree6e7f71b5a9ece2d6131305509efdde22b97a621d
parent21fc42b2d594986a4ae28475b10c75bfe10d3bd2
[libc] Fix printf %f rounding condition

When running the tbin2dec tests I found a rounding error in my code.
Upon inspection I realized it was due to a lack of parenthesis when
calculating the number of trailing digits. This patch fixes that mistake
and adds unit tests to catch regressions in future.

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D145011
libc/src/stdio/printf_core/float_dec_converter.h
libc/test/src/stdio/sprintf_test.cpp