CINT Function
----------------------------------------------------------------------------
Action
Converts a numeric expression to an integer by rounding the fractional part
of the expression.
Syntax
CINT( numeric-expression)
Remarks
If numeric-expression is not between -32,768 and 32,767, inclusive,
BASIC generates the run-time error message Overflow.
CINT differs from the FIX and INT functions, which truncate, rather than
round, the fractional part. See the example for the INT function for an
illustration of the differences among these functions.
See Also
CCUR, CDBL, CLNG, CSNG, FIX, INT
Example
The following example converts an angle in radians to an angle in degrees
and minutes.
' Set up constants for converting radians to degrees.
CONST PI=3.141593, RADTODEG=180.-PI
INPUT "Angle in radians = ",Angle' Get the angle in radians.
Angle = Angle * RADTODEG' Convert radian input to degrees.
Min = Angle - INT(Angle)' Get the fractional part.
' Convert fraction to value between 0 and 60.
Min = CINT(Min * 60)
Angle = INT(Angle)' Get whole number part.
IF Min = 60 THEN' 60 minutes = 1 degree.
Angle = Angle + 1
Min = 0
END IF
PRINT "Angle equals"; Angle; "degrees"; Min; "minutes"
Output
Angle in radians = 1.5708
Angle equals 90 degrees 0 minutes