Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Extended KotD #25, #26, and #27: INTEGER DIVISION, CINT, and CLNG
#5
@mdijkens
Int also does rounding, I think that it rounds toward zero, so as long as the argument is positive it will give the integer-part
here's the above snippet modded a bit
Code: (Select All)

For i = 1 To 10
    x = i + .5
    Print x, Int(-x)
Next
output
Code: (Select All)

1.5          -2
2.5          -3
3.5          -4
4.5          -5
5.5          -6
6.5          -7
7.5          -8
8.5          -9
9.5          -10
10.5        -11
if you are sure that you don't want any rounding then use Fix

but if your language doesn't have the Ceil function then you can fake it
Ceil(x) = -Int(-x)
Reply


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



Users browsing this thread: 5 Guest(s)