6
Answers

Strange decimal behaviour

Photo of Rousseau Sennett

Rousseau Sennett

14y
3.3k
1

Hi

I discovered some strange decimal behaviour when subtracting values.

I think an example will explain better.

1000000.90 + 1000000.60 = 2000001.5 (which is correct)

1000000.90 - 1000000.60 = 0.300000000046566 (????)

I am using the MSScriptControl to calculate this. So I doubt the mistake is on my side?

I found similar issues online with java but there was no clear solution. Also the code is for a calculator so I need a solution that not necessarily handles only a specific number of decimals.

Any help would be appreciated

Thx Rousseau

Answers (6)

Next Recommended Forum