Y
Yannick59000
Hi, all, I'm trying to use the following function in Excel 2003's VBA:
Function myTest(ByVal X As Double, ByVal Y As Integer) As Double
myTest = Int(X * 10 ^ Y)
End Function
Nothing simpler, uh? Yet, try as I may, I cannot figure out the reason why
myTest(0.12, 5) gives 11,999 instead of 12,000.
If we do a step by step:
X = 0.12
Y = 5
10^Y = 10^5 = 100,000
X*Y = 0.12 * 100,000 = 12,000
INT(X*Y) should be 12,000...
Can anyone crack this for me...?
Thanks for your help,
-Yannick.
Function myTest(ByVal X As Double, ByVal Y As Integer) As Double
myTest = Int(X * 10 ^ Y)
End Function
Nothing simpler, uh? Yet, try as I may, I cannot figure out the reason why
myTest(0.12, 5) gives 11,999 instead of 12,000.
If we do a step by step:
X = 0.12
Y = 5
10^Y = 10^5 = 100,000
X*Y = 0.12 * 100,000 = 12,000
INT(X*Y) should be 12,000...
Can anyone crack this for me...?
Thanks for your help,
-Yannick.