1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-05 17:00:26 +00:00
qb64/internal/help/CINT.txt
2016-03-18 08:36:04 -03:00

35 lines
1.4 KiB
Plaintext

The {{KW|CINT}} function rounds decimal point numbers up or down to the nearest {{KW|INTEGER}} value.
{{PageSyntax}}
:: value = '''CINT('''''expression''''')'''
{{Parameters}}
* The ''expression'' is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
{{PageDescription}}
* 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 {{KW|CINT}} is used for integer values, the input values cannot exceed 32767 to -32768!
* Use {{KW|CLNG}} for {{KW|LONG}} integer values exceeding Integer limitations.
* Note: When decimal point values are given to Basic functions requiring [[INTEGER]]s the value will be CINTed.
''Example:'' Shows how CINT rounds values up or down as in bankers rounding.
{{CodeStart}} '' ''
a% = {{Cl|CINT}}(1.49): b% = {{Cl|CINT}}(1.50): c = 11.5
{{Cl|COLOR}} c: {{Cl|PRINT}} a%, b%, c '' ''
{{CodeEnd}}
{{OutputStart}}{{text|1 2 11.5|red}}
{{OutputEnd}}
:''Note:'' Qbasic functions requiring [[INTEGER]] values such as text or graphic coordinates and {{KW|COLOR}} will be rounded like {{KW|CINT}}. Half values are rounded to the nearest even integer value.
{{PageSeeAlso}}
* {{KW|CLNG}}, {{KW|CSNG}}, {{KW|CDBL}}
* {{KW|INT}}, {{KW|FIX}}, {{KW|_ROUND}}
{{PageNavigation}}