coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] numfmt: avoid integer overflow when rounding


From: Pádraig Brady
Subject: Re: [PATCH] numfmt: avoid integer overflow when rounding
Date: Mon, 22 Jun 2015 13:57:51 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0

On 22/06/15 04:24, Pádraig Brady wrote:
> On 22/06/15 02:26, Pádraig Brady wrote:
>> Due to existing limits this is usually triggered
>> with an increased precision.  We also add further
>> restrictions to the output of increased precision numbers.
>>
>> * src/numfmt.c (simple_round): Avoid intmax_t overflow.
>> (simple_strtod_int): Count digits consistently
>> for precision loss and overflow detection.
>> (prepare_padded_number): Include the precision
>> when excluding numbers to output, since the precision
>> determines the ultimate values used in the rounding scheme
>> in double_to_human().
>> * tests/misc/numfmt.pl: Add previously failing test cases.
>> * NEWS: Mention the fix.
> 
> Related to more portable precision handling,
> I'll squash this in:
> 
> -enum { MAX_UNSCALED_DIGITS = 18 };
> +enum { MAX_UNSCALED_DIGITS = LDBL_DIG };

There were some related portability assumptions in the tests,
so I'll apply the attached separated patch instead.

thanks,
Pádraig.

Attachment: numfmt-limits.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]