C: difference between (int)x and floor(x)?
Posted
by igul222
on Stack Overflow
See other posts from Stack Overflow
or by igul222
Published on 2010-04-08T23:57:20Z
Indexed on
2010/04/09
0:03 UTC
Read the original article
Hit count: 199
c
|floating-point
In C, what is the difference between these two?
float myF = 5.6;
printf( "%i \n", (int)myF ); // gives me "5"
printf( "%ld \n", floor(myF) ); // also "5"?
When is one preferable over the other?
© Stack Overflow or respective owner