Mod and Modulus (Float functions): Difference between revisions
mNo edit summary |
mNo edit summary |
||
Line 13: | Line 13: | ||
The Modulus function is available as of version 7.3 of the [[Sirius Mods]]. | The Modulus function is available as of version 7.3 of the [[Sirius Mods]]. | ||
== | ==Syntax== | ||
{{Template:Float:Mod syntax}} | {{Template:Float:Mod syntax}} | ||
{{Template:Float:Modulus syntax}} | {{Template:Float:Modulus syntax}} | ||
===Syntax terms=== | |||
<dl> | <dl> | ||
<dt>%mod | <dt>%mod | ||
Line 25: | Line 25: | ||
<dd>A non-zero numeric value. A value of 0, or a value that rounds down to 0, causes a request cancellation. | <dd>A non-zero numeric value. A value of 0, or a value that rounds down to 0, causes a request cancellation. | ||
</dl> | </dl> | ||
==Examples== | |||
The following statement returns to %z the remainder from the division of | The following statement returns to %z the remainder from the division of | ||
the number in %x (rounded) by the number in %y (rounded): | the number in %x (rounded) by the number in %y (rounded): | ||
Line 44: | Line 44: | ||
%dividend:mod(%divisor) = 1 | %dividend:mod(%divisor) = 1 | ||
==See also== | |||
[[List of intrinsic Float methods]] | [[List of intrinsic Float methods]] | ||
[[Category: Intrinsic Float methods|Mod and Modulus function]] | [[Category: Intrinsic Float methods|Mod and Modulus function]] |
Revision as of 13:56, 19 January 2011
Template:Float:Modulus subtitle
These intrinsic functions return the remainder from the division of the method object by the method argument. The numbers to be divided are first rounded to an integer, including zero, so the remainder is always an integer or zero.
Mod is a synonym for Modulus.
The Div function returns the integral quotient of a division.
The Modulus function is available as of version 7.3 of the Sirius Mods.
Syntax
%number = float:Mod( divisor)
%number = float:Modulus( divisor)
Syntax terms
- %mod
- A variable to receive the integral remainder of the quotient of number / num.
- number
- A Float value to be divided by the method argument, num.
- num
- A non-zero numeric value. A value of 0, or a value that rounds down to 0, causes a request cancellation.
Examples
The following statement returns to %z the remainder from the division of the number in %x (rounded) by the number in %y (rounded):
%z = %x:mod(%y)
The following statement returns -1 to %z:
%z = -191.4:mod(2.0)
The following displays the quotient and remainder when dividing 9997 by 7:
b %dividend is float %divisor is float %dividend = 9997 %divisor = 7 printText {~} = {%dividend:div(%divisor)} printText {~} = {%dividend:mod(%divisor)} end
so displays:
%dividend:div(%divisor) = 1428 %dividend:mod(%divisor) = 1
See also
List of intrinsic Float methods