FutureBasic Logo

<<    Index    >> FutureBasic

int   function



Syntax
nearestInteger = int(expr)

Description
Rounds, via the C function, rint(), the provided floating-point expression( expr ) and returns the nearest integral value.
int accepts a type double input and returns the integral value in a type double.

Notes
int returns a long integer value, which means the integer portion of expr should be within the maximum range for that integer type. If the returned rounded value is outside the range of the return variable's integer type, the numeric result is invalid. To obtain the integer part of numbers which are outside this range, use the fix function, but note however that fix truncates the fraction part rather than rounding to the nearest integer. In general, fix and int don't return the same values.

All the math.incl header C functions, including rint() are available via the math.incl header. The FB Editor recognizes them and they can be called directly.
Documentation for the math.incl calls can be found in Terminal.app by issuing the 'man' command with the function name (e.g. 'man floor') appended.

See also
fix; frac; Appenix R - Rounding Options