Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion newlib/libc/tinystdio/dtoa_ryu.c
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ d2d(const uint64_t ieeeMantissa, const uint32_t ieeeExponent, int max_digits, bo

// We need to take vr + 1 if vr is outside bounds or we need to round up.
// I don't know if the 'truncate_max' case is entirely correct; need some tests
uint8_t carry = ((!truncate_max && vr == vm && (!acceptBounds || !vmIsTrailingZeros)) || lastRemovedDigit >= 5);
uint8_t carry = (((!truncate_max && vr == vm && (!acceptBounds || !vmIsTrailingZeros)) || lastRemovedDigit >= 5) && !(fmode && max_decimals == 0));
output += carry;

int len = decimalLength17(output);
Expand Down
1 change: 1 addition & 0 deletions test/testcases.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@
result |= test(__LINE__, "8.6000", "%2.4f", 8.6);
result |= test(__LINE__, "0.600000", "%0f", 0.6);
result |= test(__LINE__, "1", "%.0f", 0.6);
result |= test(__LINE__, "0", "%.0f", 0.45);
result |= test(__LINE__, "8.6000e+00", "%2.4e", 8.6);
result |= test(__LINE__, " 8.6000e+00", "% 2.4e", 8.6);
result |= test(__LINE__, "-8.6000e+00", "% 2.4e", -8.6);
Expand Down