3 ms·
Why does pow(n,2) return 24 when n=5, with my compiler and OS?
- HarHarVeryFunny 3y agoTitle is a bit misleading, it's really referring to "(int) pow(n,2)", and happens since pow() is a floating point function, and default float to int conversion is by truncation. i.e. if pow(5,2) is 24.999, then (int) pow(5,2) is 24. If you want 25, then use round(pow(5,2)) instead.