Difference between revisions of "ROUND"

From QB64 Wiki
Jump to navigation Jump to search
imported>Cyperium
imported>SMcNeill
(style guidelines)
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The {{KW|_ROUND}} function rounds to the closest {{KW|INTEGER}}, {{KW|LONG}} or {{KW|_INTEGER64}} numerical value.
{{DISPLAYTITLE:_ROUND}}
The [[_ROUND]] function rounds to the closest even [[INTEGER]], [[LONG]] or [[_INTEGER64]] numerical value.




{{PageSyntax}}
{{PageSyntax}}
:<code>{{Parameter|variable}} = {{KW|ROUND}} ({{Parameter|variable}})</code>
: {{Parameter|value}} = [[_ROUND]]({{Parameter|number}})




{{PageDescription}}
{{PageDescription}}
* Can be used when numerical values exceed the limits of {{KW|CINT}} or {{KW|CLNG}}.
* Can round [[SINGLE]], [[DOUBLE]] or [[_FLOAT]] floating decimal point parameter values.
* Can be used when numerical values exceed the limits of [[CINT]] or [[CLNG]].
* Rounding is done to the closest even [[INTEGER|integer]] value. The same as QBasic does with [[\|integer division]].




''Example:'' Displays how QB64 rounds to the closest even integer value.
{{CodeStart}}
{{Cl|PRINT}} {{Cl|_ROUND}}(0.5)
{{Cl|PRINT}} {{Cl|_ROUND}}(1.5)
{{Cl|PRINT}} {{Cl|_ROUND}}(2.5)
{{Cl|PRINT}} {{Cl|_ROUND}}(3.5)
{{Cl|PRINT}} {{Cl|_ROUND}}(4.5)
{{Cl|PRINT}} {{Cl|_ROUND}}(5.5) '' ''
{{CodeEnd}}
{{OutputStart}}0
2
2
4
4
6
{{OutputEnd}}
''See also:''
* [[INT]], [[CINT]]
* [[FIX]], [[CLNG]]




{{PageNavigation}}
{{PageNavigation}}

Latest revision as of 00:09, 9 September 2017

The _ROUND function rounds to the closest even INTEGER, LONG or _INTEGER64 numerical value.


Syntax

value = _ROUND(number)


Description


Example: Displays how QB64 rounds to the closest even integer value.

PRINT _ROUND(0.5) PRINT _ROUND(1.5) PRINT _ROUND(2.5) PRINT _ROUND(3.5) PRINT _ROUND(4.5) PRINT _ROUND(5.5)

0 2 2 4 4 6


See also:



Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page