Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extended KotD #25, #26, and #27: INTEGER DIVISION, CINT, and CLNG
#10
Note that after some testing, _ROUND also behaves exactly the same as CINT and CLNG.  It's simply for a larger range of areas.

value < 0.5 rounds down.
value = 0.5 rounds to the nearest even integer.
value > 0.5 rounds up.

Code: (Select All)
For x = -10.5 To 10.5
    Print x - .01; _Round(x - .01),
    Print x; _Round(x),
    Print x + .01; _Round(x + .01)
Next

Its wiki page needs a complete update and overhaul as well to indicate this behavior properly as it simply says:

Quote:Rounding is done to the closest even integer value. 


And, as you can see from the above, that statement only holds true when dealing with 0.5 values directly.  All others round up or down to the nearest integer, even if that's an odd number.
Reply


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

Possibly Related Threads…
Thread Author Replies Views Last Post
  Extended KotD #23 and #24: _MIN and _MAX SMcNeill 0 590 01-16-2025, 09:51 AM
Last Post: SMcNeill
  Extended KotD #22: _MOUSEHIDDEN SMcNeill 0 595 01-14-2025, 12:29 AM
Last Post: SMcNeill
  Extended KotD #20: _NOTIFYPOPUP SMcNeill 4 1,302 12-05-2024, 01:55 AM
Last Post: Pete
  Extended KotD #21: _MIDISOUNDBANK a740g 8 2,709 08-30-2024, 07:32 PM
Last Post: Steffan-68
  Extended KotD #19: _UCHARPOS SMcNeill 1 869 06-26-2024, 12:54 AM
Last Post: SMcNeill

Forum Jump:


Users browsing this thread: