07-02-2024, 07:19 AM
I'd never swear to this type of glitch being fully squashed. VAL returns a floating point value to us. Not all floating point values work out to be exactly what we'd think they might be. x = VAL("10") may somehow magically return a value of 9.9999999999999999 due to the way floating point numbers work. QB4PE tries to avoid this issue, as much as possible, but it's an underlying component of just the way floating point works.
Any time you work with floating point values, I'd never swear that you'd get exact integers. If you want integers, then assign it to an integer variable. Chances are, if the value ends up being 9.99999999999 or 1.0000000000001e12, or whatever, it'll end up rounding to the proper value for you naturally.
Any time you work with floating point values, I'd never swear that you'd get exact integers. If you want integers, then assign it to an integer variable. Chances are, if the value ends up being 9.99999999999 or 1.0000000000001e12, or whatever, it'll end up rounding to the proper value for you naturally.
Code: (Select All)
x$ = "9"
x& = Val(x$)
x = x&
Print x
End