AlphaFrog
MrExcel MVP
- Joined
- Sep 2, 2009
- Messages
- 16,563
I don't understand why the Int function rounds down the value of 2 down to 1 in the second calculation?
Code:
[COLOR=darkblue]Sub[/COLOR] Foo()
[COLOR=green]'Correct result = 2[/COLOR]
Debug.Print (0.15 - 0.07) / 0.04
[COLOR=green]'Why does Int round down the result of 2 to 1 ?[/COLOR]
[COLOR=#ff0000] Debug.Print Int((0.15 - 0.07) / 0.04)[/COLOR]
[COLOR=green]'Yet this is correct = 2[/COLOR]
Debug.Print [COLOR=darkblue]CInt[/COLOR]((0.15 - 0.07) / 0.04)
[COLOR=green]'And this is correct = 2[/COLOR]
Debug.Print Int(0.08 / 0.04)
[COLOR=darkblue]End[/COLOR] [COLOR=darkblue]Sub[/COLOR]