Quantcast
Channel: User Federico klez Culloca - Stack Overflow
Viewing all articles
Browse latest Browse all 502

Answer by Federico klez Culloca for Why is it not allowed to assign double literal to variable of type float?

$
0
0

Because an int fits inside a long, but if you put a double inside a float you may lose precision (it's a narrower type).

If you really must you can force this via casting

double d = 4.0;float f = (float)d; // this is allowed

Viewing all articles
Browse latest Browse all 502

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>