Yes, it's guaranteed.
§6.2.5 (Types) para 10:
- There are three real floating types, designated as float, double, and long double. The set of values of the type float is a subset of the set of values of the type double…
§6.3.1.5 (Conversions of real floating types) para 1:
- When a value of real floating type is converted to a real floating type, if the value being converted can be represented exactly in the new type, it is unchanged.
Since the values of float
are a subset of the values of double
, the float
's value can be represented exactly as a double
so it is unchanged. The resulting double
therefore has an exact float
representation so it will be converted back unchanged.
As has been pointed out, the fact that the value is unchanged does not mean it will compare equal since it might be a NaN. But both or neither will be NaN.