We have just encountered a problem with using exponentiation inside the INT() function with regards to the SET DECIMALS setting. Below is sample code for you to try in your command window.
SET DECIMALS TO 2
l_nNewValue = 4.9811
? INT(l_nNewValue*(10^5)) / (10^5) = 4.9811
? INT(l_nNewValue*10*10*10*10*10) / (10*10*10*10*10) = 4.9811
SET DECIMALS TO 4
l_nNewValue = 4.9811
? INT(l_nNewValue*(10^5)) / (10^5) = 4.9811
? INT(l_nNewValue*10*10*10*10*10) / (10*10*10*10*10) = 4.9811
This code should return the following on your screen:
.T.
.T.
.T.
.T.
but instead returns:
.T.
.T.
.F.
.T.
With SET DECIMALS TO 4 it is returning 498109 when using the (10^5) inside the INT() function but should be returning 498110 just like all the other equations. Why is this happening? Why does it work when set decimals is 2 and not when it is 4? Is their a setting I am missing? I know I can avoid the exponentiation equation and type out the 10*10 five times but my trust in VFP to return a correct mathimatical result will be diminished.
I did do a search and the only thing I saw that mentioned anything close this is Thread184-407116 and that had to due with double rounding.
Any help is much appreciated.
Thanks,
Dave L.
SET DECIMALS TO 2
l_nNewValue = 4.9811
? INT(l_nNewValue*(10^5)) / (10^5) = 4.9811
? INT(l_nNewValue*10*10*10*10*10) / (10*10*10*10*10) = 4.9811
SET DECIMALS TO 4
l_nNewValue = 4.9811
? INT(l_nNewValue*(10^5)) / (10^5) = 4.9811
? INT(l_nNewValue*10*10*10*10*10) / (10*10*10*10*10) = 4.9811
This code should return the following on your screen:
.T.
.T.
.T.
.T.
but instead returns:
.T.
.T.
.F.
.T.
With SET DECIMALS TO 4 it is returning 498109 when using the (10^5) inside the INT() function but should be returning 498110 just like all the other equations. Why is this happening? Why does it work when set decimals is 2 and not when it is 4? Is their a setting I am missing? I know I can avoid the exponentiation equation and type out the 10*10 five times but my trust in VFP to return a correct mathimatical result will be diminished.
I did do a search and the only thing I saw that mentioned anything close this is Thread184-407116 and that had to due with double rounding.
Any help is much appreciated.
Thanks,
Dave L.