note 24182 deleted from language.types.float by nlopess
| From: | nlopess@php.net | Date: | Tue, 06 Jul 2004 09:39:46 +0000 |
| Subject: | note 24182 deleted from language.types.float by nlopess | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-72743@lists.php.net to get a copy of this message | ||
Note Submitter: jnm@mormino.net
----
[Editor's note: the contributor did not see number_format(), sprintf() and other similar
functions that can accomplish this task.]
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;
}