...

# Recurring number eg . 1.3333333 How do i make it to 2 decimal places HELP

maxvee8
03-17-2008, 02:01 AM
how would i make the recurring number to 2 decimal places eg . 1.33 or even 0 decimal places eg 1

Image to see problem http://img357.imageshack.us/img357/6929/recurerrortl7.jpg

\$burgans08 = ((\$burg08 / \$burg07) * 100)-100;
\$stabans08 = ((\$stab08 / \$stab07) * 100)-100;

if(\$burgans08<0){
echo "<div id='ansburg08'><b>" .\$burgans08. "%</b> Decrease in burglary since 2007</div>";
}
if(\$burgans08>0){
echo "<div id='ansburg08'><b>" .\$burgans08. "%</b> Rise in burglary since 2007</div>";
}
if(\$burgans08==0){
echo "<div id='ansburg08'><b>" .\$burgans08. "%</b> Burglary is the same since 2007</div>";
}

\$burgans08
\$stabans08

those variable are givind me the answer to the equation so how would i format the answer to 2 decimal places eg . 1.33 or even 0 decimal places eg 1

Max

oesxyl
03-17-2008, 02:08 AM
echo round("1.33333",2);
echo round("1.66666",3);

not tested, :confused::eek::cool:

http://www.php.net/manual/en/function.round.php

best regards

maxvee8
03-17-2008, 02:17 AM
ok that worked thanks