CINT - QB64 Wiki


From QB64 Wiki

Jump to: navigation, search

The CINT function rounds decimal point numbers up or down to the nearest INTEGER value.


value = CINT(expression)


  • The expression is any TYPE of literal or variable numerical value or mathematical calculation.


  • Values greater than .5 are rounded up. Values lower than .5 are rounded down just like "bankers rounding".
  • Half(.5) SINGLE values are rounded to the nearest EVEN integer value whether it is up or down.
  • 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.

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

Note: Qbasic functions requiring INTEGER values such as text or graphic coordinates and COLOR will be rounded like CINT. Half values are rounded to the nearest even integer value.

See also:

Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page
Personal tools