05-04-2025, 06:51 PM
(05-04-2025, 05:13 PM)Steffan-68 Wrote:(05-04-2025, 04:44 PM)SMcNeill Wrote: From what I can tell we seem to mimic QB45 perfectly. It's just we haven't really documented this behavior and explained it very well for people in the past. The wiki is woefully lacking important details about exactly how people should expect CINT, CLNG, and _ROUND to work.But you should also say that this is only the case with one decimal place.
from 0.55 the behavior is changed .
Code: (Select All)
For i = 1 To 10
x = i + .55
Print x, CInt(x)
Next
Code: (Select All)
1.55 2
2.55 3
3.55 4
4.55 5
5.55 6
6.55 7
7.55 8
8.55 9
9.55 10
10.55 11
That's why I mentioned this:
value < 0.5 rounds down.
value = 0.5 rounds to the nearest even integer.
value > 0.5 rounds up.
X.49999999999999 rounds down.
x.50000000000001 rounds up.