Rousseau Sennett

Rousseau Sennett

  • NA
  • 31
  • 43.1k

Strange decimal behaviour

Jul 6 2011 9:20 AM

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)