\: Difference between revisions
Jump to navigation
Jump to search
Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link
No edit summary |
No edit summary |
||
(2 intermediate revisions by the same user not shown) | |||
Line 2: | Line 2: | ||
{{PageSyntax}} | {{PageSyntax}} | ||
: {{Parameter|return_value}} = {{Parameter|number}} [[\]] {{Parameter|divisor}} | : {{Parameter|return_value}} = {{Parameter|number}} [[\]] {{Parameter|divisor}} | ||
Line 11: | Line 11: | ||
* Return values will be [[INTEGER]] or [[LONG]] value types only. | * Return values will be [[INTEGER]] or [[LONG]] value types only. | ||
* Rounding is done to the closest EVEN [[INTEGER|integer]] or [[LONG|long integer]] value. | * Rounding is done to the closest EVEN [[INTEGER|integer]] or [[LONG|long integer]] value. | ||
* Use the [[/]] | * Use the [[/|/ normal division]] operator for [[SINGLE]] or [[DOUBLE]] floating decimal point return values. | ||
* Division and multiplication operations are performed before addition and subtraction in QBasic's order of operations. | * Division and multiplication operations are performed before addition and subtraction in QBasic's order of operations. | ||
Line 23: | Line 23: | ||
{{Cl|PRINT}} 3.5 \ 1 | {{Cl|PRINT}} 3.5 \ 1 | ||
{{Cl|PRINT}} 4.5 \ 1 | {{Cl|PRINT}} 4.5 \ 1 | ||
{{Cl|PRINT}} 5.5 \ 1 | {{Cl|PRINT}} 5.5 \ 1 | ||
{{CodeEnd}} | {{CodeEnd}} | ||
{{OutputStart}}0 | {{OutputStart}}0 | ||
Line 39: | Line 39: | ||
{{PageNavigation}} | {{PageNavigation}} | ||
Latest revision as of 03:01, 23 January 2023
The \ mathematical operator performs INTEGER division on a numerical value.
Syntax
- return_value = number \ divisor
Description
- Number value can be any literal or variable numerical type.
- Divisor (second value) must not be a value of 0 to .5. This will create a "Division by zero" error! due to CINT rounding.
- Return values will be INTEGER or LONG value types only.
- Rounding is done to the closest EVEN integer or long integer value.
- Use the / normal division operator for SINGLE or DOUBLE floating decimal point return values.
- Division and multiplication operations are performed before addition and subtraction in QBasic's order of operations.
Examples
- Example
- Displays how floating decimal point values are rounded to the closest even integer value.
PRINT 0.5 \ 1 PRINT 1.5 \ 1 PRINT 2.5 \ 1 PRINT 3.5 \ 1 PRINT 4.5 \ 1 PRINT 5.5 \ 1 |
0 2 2 4 4 6 |
See also