Archived

This topic is now archived and is closed to further replies.

Decimal Help

Recommended Posts

Hello,

I have a quick question. I am doing a stats program for a hockey team and the question I have is that I have the decimals correct for the goaltenders goals against average and save % as I wish, except for the fact that if its an even # like 2 it will display 2 rather than 2.00. Works fine when the #'s are not even rounding off to 2 and 3 decimals respectively.

Here is the code for the GAA....

\$p_array[\$playerid][gaa] = ROUND('1.00' * (\$p_array[\$playerid][goalsa]) * (60/\$p_array[\$playerid][minutes]), 2);

Any help would be appreciated......thanks in advance !

Share on other sites
http://ca.php.net/manual/en/function.number-format.php

Share on other sites
thanks, thought there may have been something I could do here in this snippet....

\$p_array[\$playerid][gaa] = ROUND('1.00' * (\$p_array[\$playerid][goalsa]) * (60/\$p_array[\$playerid][minutes]), 2);

like this....

\$p_array[\$playerid][gaa] = ROUND('1.00' * (\$p_array[\$playerid][goalsa]) * (60/\$p_array[\$playerid][minutes]), 2,'.',' ');

Share on other sites
wrap number_format around your round function:
[code=php:0]\$pcent = round('1.00' * (\$p_array[\$playerid]['goalsa']) * (60/\$p_array[\$playerid]['minutes']), 2);

\$p_array[\$playerid]['gaa'] = number_format(\$pcent, 2, '.', ',');[/code]

Share on other sites
Thanks so much.....works beautiful.