Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extended KotD #25, #26, and #27: INTEGER DIVISION, CINT, and CLNG
#9
Dang I did not know Integer division was a problem! (Giving results unexpected like CINT and CLNG which I never use anyway)

Round2 gives me results I'd prefer as expected, has this been proposed before? (expected round up on .5 or down if negative)
Code: (Select All)
For i = -5 To 5 Step .5
    Print i, round2&(i), _Round(i)
Next
Function round2& (x)
    If x < 0 Then round2& = -1 * Int(-x + .5) Else round2& = Int(x + .5)
End Function

I vaguely remember some conversation about rounding and Luke mentioning that rounding in QB64 was like bankers way of rounding .5's so that a balance of them doesn't accumulate a significant plus amount.
b = b + ...
Reply


Messages In This Thread
RE: Extended KotD #25, #26, and #27: INTEGER DIVISION, CINT, and CLNG - by bplus - 05-04-2025, 03:20 PM



Users browsing this thread: 4 Guest(s)