note 24182 added to language.types.float
| From: | jnm at mormino dot net | Date: | Thu, 08 Aug 2002 17:03:55 +0000 |
| Subject: | note 24182 added to language.types.float | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-34540@lists.php.net to get a copy of this message | ||
I'm sure there is an easier way to float a number to a desired precision, but I couldn't
find one. So, here is a function that floats 1 decimal place.
function float1($val)
{
$x = intval(10*$val)/10;
if ($x == intval($x)) return "".$x.".0";
else return intval(10*$val)/10;
}
--
http://www.php.net/manual/en/language.types.float.php
http://master.php.net/manage/user-notes.php?action=edit+24182
http://master.php.net/manage/user-notes.php?action=delete+24182
http://master.php.net/manage/user-notes.php?action=reject+24182