On 11/29/2011 03:23 PM, Jim Meyering wrote:
>>> @@ -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.
> 

You missed my point - the compiler is going to be converting float to
double to pass the argument to fprintf, and fprintf will be operating on
double (%f and %lf both mean double on printf; they only differ on float
vs. double when dealing with scanf).  I see your point about the
possibility of the intermediate division in float possibly being faster,
but no matter how we look at things, the end result is still fprintf
operating on double, not float, whether or not we cared about the extra
precision.

-- 
Eric Blake   ebl...@redhat.com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to