Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

math question dealing with money (decimals)

Status
Not open for further replies.

csphard

Programmer
Apr 5, 2002
194
US
I have 2 fields in my table
quantity int(11)
price decimal(3,2)

In my php I perform the following arithmetic

($price * $qty)


9.00 * 1 it returns 9 but I want this to be 9.00
9.00 * 2 it returns 18 but I want this to be 18.00

What do I have to do to get the cents to display if it is 00.

howard
 
I found my answer:

number_format(($price * $qty),2)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top