[Mesa-dev] [PATCH] nir: Use double-precision pow() when bit_size is 64, powf() otherwise

Patrick Baggett baggett.patrick at gmail.com
Mon Mar 28 19:05:09 UTC 2016


On Mon, Mar 28, 2016 at 1:58 PM, Patrick Baggett
<baggett.patrick at gmail.com> wrote:
>> What are the rules in C when you compare a double
>> variable with a single constant?
>>
>> void foo(double d)
>> {
>>     /* Does d get converted to single, or does 0.0f get converted to
>>      * double?
>>      */
>>     if (d == 0.0f)
>>         printf("zero\n");
>> }
>
> The 0.0f is converted to a double. One site [1] has a likely looking
> reference. :) Sadly, I don't know how to check the C spec directly (I
> think that it is not free).
>
> [1] https://www.eskimo.com/~scs/cclass/int/sx4cb.html

Nevermind, the spec is available..found the link via Wikipedia.

6.3.1.8 Usual arithmetic conversions
1
....
Otherwise, if the corresponding real type of either operand is double,
the other operand is converted, without change of type domain, to a
type whose corresponding real type is double.

So yes, 100% sure that it is promoted to a double.


More information about the mesa-dev mailing list