mirror of
https://github.com/apache/nuttx.git
synced 2026-05-21 21:22:17 +08:00
libc/stdio: fix rounding errors for fractional values less than 1
Signed-off-by: wangxuedong <wangxuedong@xiaomi.com>
This commit is contained in:
@@ -127,12 +127,13 @@ int __dtoa_engine(double x, FAR struct dtoa_s *dtoa, int max_digits,
|
||||
|
||||
/* If limiting decimals, then limit the max digits to no more than the
|
||||
* number of digits left of the decimal plus the number of digits right
|
||||
* of the decimal
|
||||
* of the decimal. If the integer value is 0, there are only values to
|
||||
* the right of the decimal point in dtoa->digits.
|
||||
*/
|
||||
|
||||
if (max_decimals != 0)
|
||||
{
|
||||
max_digits = MIN(max_digits, max_decimals + MAX(exp + 1, 1));
|
||||
max_digits = MIN(max_digits, max_decimals + MAX(exp + 1, 0));
|
||||
}
|
||||
|
||||
/* Round nearest by adding 1/2 of the last digit before converting to
|
||||
|
||||
Reference in New Issue
Block a user