mirror of
https://github.com/QB64Official/qb64.git
synced 2024-09-28 11:17:47 +00:00
35 lines
1.1 KiB
Text
35 lines
1.1 KiB
Text
The [[CINT]] function rounds decimal point numbers up or down to the nearest [[INTEGER]] value.
|
|
|
|
|
|
{{PageSyntax}}
|
|
: {{Parameter|value%}} = [[CINT]]({{Parameter|expression}})
|
|
|
|
|
|
{{PageParameters}}
|
|
* {{Parameter|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.
|
|
* ''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 [[INTEGER]]s the value will be [[CINT]]ed.
|
|
|
|
|
|
{{PageExamples}}
|
|
''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}}
|
|
|
|
|
|
{{PageSeeAlso}}
|
|
* [[_ROUND]], [[_CEIL]]
|
|
* [[CLNG]], [[CSNG]], [[CDBL]]
|
|
* [[INT]], [[FIX]]
|
|
|
|
|
|
{{PageNavigation}}
|