You never lose accuracy when converting from float (i.e. float32) to double (float64). The former should be a subset of the latter.
This has more to do with the default accuracy of the output formatter.
Nearest IEEE754 float up to 359.9
359.899993896484375
Nearest IEEE754 double to 359.9
359.8999999999999772626324556767940521240234375
Nearest IEEE754 double to 359.899993896484375
359.899993896484375
(i.e. the same thing, due to the subset rule that I already mentioned).
So you can see that float64(a) matches float64(359.899993896484375) , which is 359.899993896484375 . This explains the output, although your formatter rounds the last 2 digits.
user6300394
source share