Link to home
Start Free TrialLog in
Avatar of kch011099
kch011099

asked on

Adding places in decimals

I am doing a little bit of adding in a script, but when I add the numbers, the script removes the decimal or some of the places after the decimal.

For example: 24.50 + 24.50 = 89
             24.50 = 24.5

I need to keep the 2 places after the decimal. How can I do that?
ASKER CERTIFIED SOLUTION
Avatar of sbuehrle
sbuehrle

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ozo
printf "%.2f",24.50 + 24.50;
#or work with exact integer cents instead of approximate floating dollars to avoid round off errors