CINT: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
No edit summary |
mNo edit summary |
||
Line 1: | Line 1: | ||
The [[CINT]] function rounds decimal point numbers up or down to the nearest [[INTEGER]] value. | The [[CINT]] function rounds decimal point numbers up or down to the nearest [[INTEGER]] value. (IF the number ends in exactly 0.5, then it is rounded to the nearest EVEN integer value.) | ||
Line 12: | Line 12: | ||
{{PageDescription}} | {{PageDescription}} | ||
* Values greater than .5 are rounded up. Values lower than .5 are rounded down. | * Values greater than .5 are rounded up. Values lower than .5 are rounded down. | ||
* Values that are exactly .5 are rounded to the nearest even integer. | |||
* ''Warning:'' Since [[CINT]] is used for integer values, the input values cannot exceed 32767 to -32768! | * ''Warning:'' Since [[CINT]] is used for integer values, the input values cannot exceed 32767 to -32768! | ||
* Use [[CLNG]] for [[LONG]] integer values exceeding [[INTEGER]] limitations. | * Use [[CLNG]] for [[LONG]] integer values exceeding [[INTEGER]] limitations. |
Revision as of 18:17, 5 May 2025
The CINT function rounds decimal point numbers up or down to the nearest INTEGER value. (IF the number ends in exactly 0.5, then it is rounded to the nearest EVEN integer value.)
Syntax
- value% = CINT(expression)
Parameters
- expression is any TYPE of literal or variable numerical value or mathematical calculation.
Description
- Values greater than .5 are rounded up. Values lower than .5 are rounded down.
- Values that are exactly .5 are rounded to the nearest even integer.
- Warning: Since CINT is used for integer values, the input values cannot exceed 32767 to -32768!
- Use CLNG for LONG integer values exceeding INTEGER limitations.
- Note: When decimal point values are given to BASIC functions requiring INTEGERs the value will be CINTed.
Examples
Example: Shows how CINT rounds values up or down as in "bankers' rounding".
a% = CINT(1.49): b% = CINT(1.50): c = 11.5 COLOR c: PRINT a%, b%, c |
1 2 11.5
|
See also