faqts : Computers : Programming : Languages : PHP

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

5 of 9 people (56%) answered Yes
Recently 5 of 9 people (56%) answered Yes

Entry

How would you specify a precision of two decimal places for the floating-point number we have been formating in the previous questions?

Mar 24th, 2008 20:03
ha mo, j. kelley, Himanshu Jain,


The precision specifier consists of dot( . )followed by a number
representing the precision you want to apply.it should be placed before
the conversion specifier:
Printf( “%04.2f” , 33);
.....
Alternately you could use the php function number_format().  For example
printf("%s", number_format((1/3),  2);
would dispay .33
http://www.tantofa.com
http://www.fantofa.com
http://www.mantofa.com
http://www.tanpola.com
http://www.tampola.com
http://www.yamot.com
http://www.mozmar.com
http://www.templatestemp.com