Posted: Fri Oct 20, 2006 7:16 pm
I ran some tests about a few ways that you could convert something into an integer.
Here's the image: http://cameri.dnsalias.com/cameri/typca ... Sround.jpg
round() returns a float, and that's not what we want, but I included it because it truncates the decimal part too.
floor(), well, it does what it should, return the nearest integer below the number.
intval(), is the function that is supposed to convert a scalar value to an integer.
and last but not least, type casting, which does nothing but truncate the number, dropping the decimal part.
EDIT: I forgot to mention that the units are in seconds, and each test case was done with 10,000 loops.
I'm running windows XP with some apps running, so I ran the loops until the standard deviation was less than 0.001 seconds.