diff options
author | Marco Paland <marco@paland.com> | 2019-01-31 19:16:30 +0100 |
---|---|---|
committer | Marco Paland <marco@paland.com> | 2019-01-31 19:16:30 +0100 |
commit | 369b7bbc988c509d68d7d62a1c438f5a8caf3835 (patch) | |
tree | f98c7912c5fa14735c5436915538d1a4326e3137 /printf.c | |
parent | e9375ed897cd86c72c9140e7ef88c184506d176c (diff) | |
download | printf-369b7bbc988c509d68d7d62a1c438f5a8caf3835.tar.gz printf-369b7bbc988c509d68d7d62a1c438f5a8caf3835.tar.bz2 printf-369b7bbc988c509d68d7d62a1c438f5a8caf3835.zip |
fix(printf): remove float comparison
Add more float test cases
Diffstat (limited to 'printf.c')
-rw-r--r-- | printf.c | 6 |
1 files changed, 1 insertions, 5 deletions
@@ -363,11 +363,7 @@ static size_t _ftoa(out_fct_type out, char* buffer, size_t idx, size_t maxlen, d if (prec == 0U) {
diff = value - (double)whole;
- if (diff > 0.5) {
- // greater than 0.5, round up, e.g. 1.6 -> 2
- ++whole;
- }
- else if ((diff == 0.5) && (whole & 1)) {
+ if ((!(diff < 0.5) || (diff > 0.5)) && (whole & 1)) {
// exactly 0.5 and ODD, then round up
// 1.5 -> 2, but 2.5 -> 2
++whole;
|