bug-gnulib
[Top][All Lists]
Advanced

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

Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-


From: Jim Meyering
Subject: Re: Removing -Wunsuffixed-float-constants, -Wdouble-promotion, -Wformat-zero-length
Date: Tue, 29 Nov 2011 23:23:06 +0100

Eric Blake wrote:
> On 11/29/2011 02:38 PM, Jim Meyering wrote:
...
> Meanwhile, your patch for adding 'F' is okay, but not for adding 'D'.
> That is,
>
>> +++ b/lib/hash.c
>> @@ -113,8 +113,8 @@ struct hash_table
>>     1.0).  The growth threshold defaults to 0.8, and the growth factor
>>     defaults to 1.414, meaning that the table will have doubled its size
>>     every second time 80% of the buckets get used.  */
>> -#define DEFAULT_GROWTH_THRESHOLD 0.8
>> -#define DEFAULT_GROWTH_FACTOR 1.414
>> +#define DEFAULT_GROWTH_THRESHOLD 0.8F
>> +#define DEFAULT_GROWTH_FACTOR 1.414F
>
> this change makes sense,
>
>> @@ -238,7 +238,7 @@ hash_print_statistics (const Hash_table *table, FILE 
>> *stream)
>>    fprintf (stream, "# buckets:         %lu\n", (unsigned long int) 
>> n_buckets);
>>    fprintf (stream, "# buckets used:    %lu (%.2f%%)\n",
>>             (unsigned long int) n_buckets_used,
>> -           (100.0 * n_buckets_used) / n_buckets);
>> +           (100.0F * n_buckets_used) / n_buckets);
>
> but this does not (in var-args, float gets promoted to double, so you
> probably aren't gaining anything by using 'float' as an intermediary,
> and starting with '100.0' as double is better to begin with).

Actually, if we cared about avoiding the warning, F would be fine there,
since it's printing to a mere %.2f format.  We certainly don't need all
of double's precision or exponent range for that.



reply via email to

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