Thebatfink
Active Member
- Joined
- Apr 8, 2007
- Messages
- 410
Hi, I am scratching my head and can not see what the issue is here..
If I enter a formula in a cell
I get the result, 500 as I expect.
If I attempt this in VBA, I consistently get the result 499?? Examples:
c is returned as 500 as you would expect. But with either Int or Fix, it returns 499 in the message prompt.
499 is returned in the message prompt.
Why does it do this? I suspect it is something to do with floating point precision perhaps, but I don't understand why exactly?
If I enter a formula in a cell
VBA Code:
=INT(559/1.118)
If I attempt this in VBA, I consistently get the result 499?? Examples:
VBA Code:
Private Sub test()
Dim a As Long
Dim b As Double
Dim c As Double
a = 559
b = 1.118
c = a / b
MsgBox c
MsgBox Int(c)
MsgBox Fix(c)
End Sub
VBA Code:
Private Sub test2()
MsgBox Int(559 / 1.118)
End Sub
Why does it do this? I suspect it is something to do with floating point precision perhaps, but I don't understand why exactly?