BB___INT

=INT= toc

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

 * 1) INT(Number)

Hints
code format="lb" print "Float value: 16 significant digits", 1e20/3, int(1e20/3) print "Integer value: more significant digits", 10^20/3, int(10^20/3) code
 * 1) 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 consistensy, you should use provided MyFloor function.
 * 2) If you are converting program from Microsoft Basic, bear in mind that it has INT behaving differently - exactly as MyFloor function.
 * 3) INT(integer/integer) essentially gives us long integer division:

Example
code format="lb" ' 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 code Produces: 2 3 0 -3

Floor of number
code format="lb" 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 code

Ceiling of number
code format="lb" 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 code

Rounding a number
code format="lb" function Round(number) ' returns a rounded number

Round = int( number+((number>0)-(number<0))/2 ) end function code

Long integer division
code format="lb" 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 code