For Programmers: Free Programming Magazines  


Home > Archive > PHP DB > November 2004 > Currency and number types...









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Currency and number types...
Mark Benson

2004-11-19, 3:56 pm

I'm trying to display data calculated by my script as a currency. The problem I have is that PHP is treating the results of the math as a 'float' number (or 'double') so I am getting results like:

12.0594393

in my table. I have tried using:

print round($foobar,2)

but that cuts off the trailing zero on numbers that comne out as, for example '12.10' or '12.00'.

Does anyone know a way to force PHP to print numbers to a set number of significant figures (i.e. 2) and stop the trailing zero suppression?

--
Mark Benson

http://homepage.mac.com/markbenson
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com