Difference between revisions of "INT"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>SMcNeill
(style guidelines)
 
Line 1: Line 1:
The '''INT''' function rounds a numeric value down to the next whole number or [[INTEGER]](toward less negative).  
+
The [[INT]] function rounds a numeric value down to the next whole number.  
  
  
 
{{PageSyntax}}
 
{{PageSyntax}}
:: result = '''INT('''''expression''''')'''
+
: {{Parameter|result}} = [[INT]]({{Parameter|expression}})
  
  
 
{{Parameters}}
 
{{Parameters}}
* The ''expression'' is any [[TYPE]] of literal or variable numerical value or mathematical calculation.
+
* {{Parameter|expression}} is any [[Data types|type]] of literal or variable numerical value or mathematical calculation.
  
  
 
{{PageDescription}}
 
{{PageDescription}}
* [[INT]] returns the first whole number [[INTEGER]] that is less than the ''expression'' value.
+
* [[INT]] returns the first whole number [[INTEGER]] that is less than the {{Parameter|expression}} value.
 
* This means that [[INT]] rounds down for both positive and negative numbers.
 
* This means that [[INT]] rounds down for both positive and negative numbers.
* Use [[FIX]] to round negative values up. It is identical to INT with positive values.
+
* Use [[FIX]] to round negative values up. It is identical to [[INT]] for positive values.
  
  
 +
{{PageExamples}}
 
''Example:'' Displaying the rounding behavior of [[INT]].
 
''Example:'' Displaying the rounding behavior of [[INT]].
 
{{CodeStart}}
 
{{CodeStart}}
Line 22: Line 23:
 
{{CodeEnd}}
 
{{CodeEnd}}
 
{{OutputStart}}
 
{{OutputStart}}
2  
+
2  
 
-3
 
-3
 
{{OutputEnd}}
 
{{OutputEnd}}
  
  
''See also:''
+
{{PageSeeAlso}}
 
* [[CINT]], [[CLNG]], [[FIX]]
 
* [[CINT]], [[CLNG]], [[FIX]]
 
* [[CSNG]], [[CDBL]]
 
* [[CSNG]], [[CDBL]]

Latest revision as of 18:12, 20 September 2017

The INT function rounds a numeric value down to the next whole number.


Syntax

result = INT(expression)


Parameters

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


Description

  • INT returns the first whole number INTEGER that is less than the expression value.
  • This means that INT rounds down for both positive and negative numbers.
  • Use FIX to round negative values up. It is identical to INT for positive values.


Examples

Example: Displaying the rounding behavior of INT.

PRINT INT(2.5) PRINT INT(-2.5)

2 -3


See also



Navigation:
Go to Keyword Reference - Alphabetical
Go to Keyword Reference - By usage
Go to Main WIKI Page