tl;dr: What\'s wrong with my Cur
(currency) structure?
tl;dr 2: Read the rest of the question please, before giving an
Usually monetary calculations require exact results, not just accurate results. float
and double
types cannot accurately represent the whole range of base 10 real numbers. For instance, 0.1 cannot be represented by a floating-point variable. What will be stored is the nearest representable value, which may be a number such as 0.0999999999999999996. Try it out for yourself by unit testing your struct - for example, attempt 2.00 - 1.10
.