Rounding Issues

Rounding Issues
0

#1

Tired of the FCC forums and mods. Delete all my threads like I asked before.


#2

Decimal precision is always a headache when it comes to programming. .toFixed() returns a string, but this challenge wants those vaues to be a number.

My advice for how to deal with the problem in this challenge is to think of the currency in terms of cents rather than dollars. In other words, multiply everything by 100 so you can deal with integers and then divide by 100 again for the returned value.


#4

You’re running into issues with floating point precision during your calculations and comparisons.


#6

for clarification… if you take .3-.2, you should end up with .1 right?

with floating point you end up with 0.09999999999999998.

so, if you do like ArielLeslie suggested, and treat currency in terms of cents. this problem will go away. 30-20 will equal 10 no matter if it is floating point or integer.