VB6 int() oddity

I just noticed this when doing some testing in a VB6 app:

(green is expected results, red is unexpected)

?int(88.941*1000)
 88941
?int(88.932*1000)
 88932
?int(88.929*1000)
 88929
?int(88.931*1000)
 88930

huh?

?88.931*1000
 
88931
?int(88931)
 88931

So what is up with that value 88.931? I’m sure there is some background processing that explains it. But for now I’m going to have to do a kludge with something like this to ensure my return values are correct

x=88.931*1000
?int(x)
 88931

In case you were wondering…I am using this to begin with to get around possible rounding problems.

  Sign up for my newsletter so you don't miss my conference & Pluralsight course announcements!  

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.