rounding down in php
- giantpanda
-
giantpanda
- Member since: Jan. 16, 2006
- Offline.
-
- Forum Stats
- Member
- Level 11
- Blank Slate
I've look all over the intraweb for a php tutorial that might have some idea about what i need.
I wan't to know if it's possible to round down to the nearest interval of 20 in just php.
anyone know how
- ListenToMyMusic
-
ListenToMyMusic
- Member since: Aug. 12, 2006
- Offline.
-
- Forum Stats
- Member
- Level 08
- Programmer
yes
<?
echo round(3.123456789012345678905, 20)
?>
makes
3.12345678901234567891
or
echo round(123456789012345678901, -20)
makes
100000000000000000000
whichever you need
or to always round down use this
<?php
function round_down($value)
{
if(is_float($value))
{
$exploded = explode(".",$value);
return $exploded[0];
}
else
{
die("Only float values can be entered.");
}
}
?>
that should help, I may be wrong, so ask others to confirm
come support us at the newgrounds.com irc chat room! - just type your nick, and your in!
- henke37
-
henke37
- Member since: Sep. 10, 2004
- Offline.
-
- Forum Stats
- Member
- Level 30
- Blank Slate
floor and ceil forces the rounding direction to be up and down.
Each time someone abuses hittest, God kills a kitten. Please, learn real collision testing.


