# Absolutely Bizarre - Code works fine, unless Dish price is set to \$X.95 or \$X.96

OK so this is bizarre to me…

All my courses sum the price correctly, EXCEPT if a dish is priced at \$X.95 or \$X.96 !

See below my code for example.

Run this and you shall see.

8.42+12.95+4.25 = \$25.62

but in this program,

8.42+12.95+4.25. = \$25.619999999999997.

How this math could give a repeating decimal is beyond me.

I have commented out the other items (as this exercises functions use random) so you can replicate the issue immediately.

All help is appreciated!

Hi,
have a look at this thread on how Javascript is calculating:
https://stackoverflow.com/questions/588004/is-floating-point-math-broken

1 Like

you can use `.toFixed(2)` to get a string for the number that shows it to 2 decimal places to make it look nicer.

``````return `Your meal is \${appetizer.name}, \${main.name}, \${dessert.name}. The price is \$\${totalPrice.toFixed(2)}.`
``````
2 Likes

Wow thank you for your help on this! Very interesting stuff