1
1
Fork 0
mirror of https://github.com/DualBrain/QB64.git synced 2023-11-19 13:10:13 +00:00
QB64-website/wiki/CINT.md
2022-12-24 19:12:43 -06:00

1,021 B

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

Syntax

value% = CINT(expression)

Parameter(s)

  • 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.
  • 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(s)

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