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?
kch011099Asked:
Who is Participating?
 
sbuehrleConnect With a Mentor Commented:
Use printf instead of print.
0
 
ozoCommented:
printf "%.2f",24.50 + 24.50;
#or work with exact integer cents instead of approximate floating dollars to avoid round off errors
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.