# INT()

Jump to navigation
Jump to search

## Description

- This function returns the integer value of the given number or expression.
- This function
**does not round**, it just returns the whole number part of a real number.- Note: There is no native command in JB to round a number. See the examples at bottom of page for a function to round a number. You can also use print using() to display rounded numbers.

## Syntax

- INT(Number)

## Hints

- In JB, INT() rounds to zero. Important thing to note that direction it rounds to is changed as you came over zero. It could affect outcome if you try to round some coordinates for example. For better consistency, you should use provided MyFloor() function.
- If you are converting program from Microsoft Basic, bear in mind that it has INT behaving differently - exactly as MyFloor() function.
- INT(integer/integer) essentially gives us long integer division:

print "Float value: 16 significant digits", 1e20/3, int(1e20/3) print "Integer value: more significant digits", 10^20/3, int(10^20/3)

## Example

' The INT is the whole number, without the fractional part. Print INT(2) Print INT(3.5) Print INT(-0.2) Print INT(-2*1.999999999) End

Produces: 2 3 0 -3

## Useful Procedures

### Floor of number

function MyFloor(number) ' returns the floor of a number ' Floor is largest integer not greater than (number) MyFloor = int(number) if MyFloor > number then MyFloor = MyFloor - 1 end function

### Ceiling of number

function MyCeil(number) ' returns the ceiling of a number ' Ceiling is smallest integer not less than (number) MyCeil = int(number) if MyCeil < number then MyCeil = MyCeil + 1 end function

### Rounding a number

function Round(number) ' returns a rounded number Round = int( number+((number>0)-(number<0))/2 ) end function

### Long integer division

function div(num1, num2) 'supposed to work on LONG integers 'returns integer part of num1/num2 with ALL digits (not 16 digits you would expect from Double) div = int(num1 / num2) end function