PDA

View Full Version : PHP Rounding Issue



dewey
July 30th, 2007, 03:17 PM
Hey Guys,

I am just finishing my first true PHP project and I am having a problem with positions after the decimal...

What I want to do is ALWAYS display percentages to 3 places after the decimal. I have the round function working, but even if the percentage is .75 I want to see .750 or .5 to be .500...

Is there a way I can do this?

Thanks,

--d

eirche
July 30th, 2007, 04:14 PM
printf('%.3f', $x);
sprintf('%.3f', $x);

dewey
July 31st, 2007, 11:26 AM
printf('%.3f', $x);
sprintf('%.3f', $x);

Thanks a lot!!