I have a text files that contain two numbers which represent monetary amounts.
When I read them in as doubles, let’s say:
double a = 73.7926
double b = 1.1
and add them together I get as a result: 74.892599999999987
where I would expect to have 74.8926
Any idea why this is and what I need to do to have my expected result without rounding ?
For that particular task you may use decimal type instead of double.
You should see: Tutorial to Understand IEEE Floating-Point Errors