I am trying to rounddown in VBA but as VBA does not support rouddown I am trying with Fix and Int functions. I know Excel itself supports rounddown but due to the coding requiremnts I need to use VBA. But I have found the follwoing annoying bug.
dblSumGross = 710000
dblCommRate = 0.0006
Now dblSumGross * dblCommRate = 426 exactly. Even rounding in Excel to 30 decimal places it is excatly 426. But when I use the Fix or Int function in my VBA code I get 425!
e.g.
dblTotalComm = Fix(dblSumGross * dblCommRate)
dblTotalComm = Int(dblSumGross * dblCommRate)
both produce a value of 425
Fix and Int functions are supposed to round non interger values down to the nearest integer but here it seems to be taking one integer 426 at taking it down to the next integer 425
This is really annoying and I am struggling to find a solution.
Anyone with any ideas about this one?
Thanks
voodoo
dblSumGross = 710000
dblCommRate = 0.0006
Now dblSumGross * dblCommRate = 426 exactly. Even rounding in Excel to 30 decimal places it is excatly 426. But when I use the Fix or Int function in my VBA code I get 425!
e.g.
dblTotalComm = Fix(dblSumGross * dblCommRate)
dblTotalComm = Int(dblSumGross * dblCommRate)
both produce a value of 425
Fix and Int functions are supposed to round non interger values down to the nearest integer but here it seems to be taking one integer 426 at taking it down to the next integer 425
This is really annoying and I am struggling to find a solution.
Anyone with any ideas about this one?
Thanks
voodoo