So, as we all know, 0.1 + 0.2
is equivalent to 0.30000000000000004
.
I've got an application which will be used at a point of sell to collect money, and I don't want to deal with the nightmare of floating point arithmetic. My options, as I see them, are
a) using integers and dealing with prices as Cents/Pence, doing the math there, and then dividing by 100 to get the cost in Dollars/Pounds
b) using a Decimal library to do accurate math on the numbers
I'm using react.js and webpack. Anybody with production experience have any advice? I'm leaning toward option a.