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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiplying variables?

Status
Not open for further replies.

Hozzer

Technical User
Jul 30, 2009
20
CA
This might be a bit of a nube question but here goes.

I have 2 variables I'm multipying
$totalCommission = $numSales * $commissions;

This runs in a foreach loop so let's say I have 2 sales at 9.25 which adds up to $18.50, why is the zero stripped off when I output $totalCommission?
 
because it is returning a float and it is correctly stating that the result is 18.5.

if you want the output formatted as a decimal number of a certain number of decimal points, use number_format()

 
Realistically speaking, trailing zeros are utterly useless.

-Geates
 
Geates,
While I agree, when displaying prices and such it does look better :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top