Why not store the number as a standard floating point, and only display to the screen the rounded number?
<?
$num = 4.215;
printf("Your rounded number is %01.1f to the nearest tenth",$num);
?>
If you DO want to store the rounded number, I would think sprintf was a much more robust (and faster) way to do it.
<?
$num = 4.215;
$rounded = sprintf("%01.1f",$num);
echo "<b>$num</b> to the nearest tenth is <b>$rounded</b>.";
?>
|