On Mon, Mar 28, 2016 at 1:58 PM, Patrick Baggett <baggett.patr...@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. _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev