PDA

View Full Version : problem with round()


smitho
04-09-2008, 01:54 AM
I'm trying to round numbers to mm and I've come across a little problem.

Here an example:


$value= 510;

$mm=28.34;

$result1=$value/$mm;

echo $result1."<br>"; //returns 17.995765702188

$result2=round($value/$mm,3);

echo $result2."<br>"; //returns 17.996

$result3=round($value/$mm,2);

echo $result3."<br>"; //returns 18
What I'm after is 180 not 18.

smitho
04-09-2008, 03:24 AM
Worked it out:



$mm=2.834;

$result3=round($value/$mm,1);

echo $result3."<br>"; //returns 180