Mod and Modulus (Float functions): Difference between revisions

From m204wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
 
(25 intermediate revisions by 5 users not shown)
Line 1: Line 1:
These [[Intrinsic classes|intrinsic]] functions return the remainder
{{Template:Float:Mod and Modulus subtitle}}
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 <var>Mod</var> and <var>Modulus</var> [[Intrinsic classes|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.


The [[Div (Float function)|Div function]] returns the integral quotient of a division.
<var>Mod</var> is a synonym for <var>Modulus</var>.


The Modulus function is available as of version 7.3 of the [[Sirius Mods]].
==Syntax==
===Modulus syntax===
{{Template:Float:Mod syntax}}
  %mod = number:Modulus(num)
{{Template:Float:Modulus syntax}}
====Syntax terms====
 
<dl>
===Syntax terms===
<dt>%mod
<table class="syntaxTable">
<dd>A variable to receive the integral remainder of the quotient of ''number'' / ''num''.
<tr><th>%number</th>
<dt>number
<td>A variable to receive the integral remainder of the quotient of <var class="term">float</var> / <var class="term">divisor</var>. </td></tr>
<dd>A Float value to be divided by the method argument, ''num''.
 
<dt>num
<tr><th>float</th>
<dd>A non-zero numeric value. A value of 0, or a value that rounds down to 0, causes a request cancellation.
<td>A <var>Float</var> value to be divided by the method argument, <var class="term">divisor</var>. </td></tr>
</dl>
 
===Examples===
<tr><th>divisor</th>
The following statement returns to %z the remainder from the division of
<td>A non-zero numeric value. A <var>divisor</var> with a value of 0, or a value that rounds down to 0, causes a request cancellation.</td></tr>
the number in %x (rounded) by the number in %y (rounded):
</table>
    %z = %x:mod(%y)
 
The following statement returns ''-1'' to %z:
==Usage notes==
    %z = -191.4:mod(2.0)
<ul>
The following displays the quotient and remainder when dividing 9997 by 7:
<li><var>Mod</var> / <var>Modulus</var> are available as of <var class="product">Sirius Mods</var> Version 7.3.
  b
</ul>
 
==Examples==
<ol><li>The following statement returns to <code>%z</code> the remainder from the division of the number in <code>%x</code> (rounded) by the number in <code>%y</code> (rounded):
<p class="code">  %z = %x:mod(%y)</p>
 
<li>The following statement returns <code>-1</code> to <code>%z</code>:
<p class="code">%z = -191.4:mod(2.0)</p>
 
<li>The following displays the quotient and remainder when dividing <code>9997</code> by <code>7</code>:
<p class="code">begin
   %dividend is float
   %dividend is float
   %divisor  is float
   %divisor  is float
   %dividend = 9997
   %dividend = 9997
   %divisor  =  7
   %divisor  =  7
   [[PrintText statement|printText]] {~} = {%dividend:div(%divisor)}
   <var>[[Intrinsic classes#printtext|printtext]]</var> {~} = {%dividend:div(%divisor)}
   printText {~} = {%dividend:mod(%divisor)}
   printText {~} = {%dividend:mod(%divisor)}
  end
end</p>
so displays:
The result is:
  %dividend:div(%divisor) = 1428
<p class="output">%dividend:div(%divisor) = 1428
  %dividend:mod(%divisor) = 1
%dividend:mod(%divisor) = 1</p>
 
</ol>
===See also===
[[List of Intrinsic Float Methods]]
[[Category: Intrinsic Float methods|Mod and Modulus function]]
[[Category: Intrinsic methods]]
[[Category:System methods]]
 


==See also==
<ul>
<li>The <var>[[Div (Float function)|Div]]</var> function returns the integral quotient of a division.
</ul>


<!--
{{Template:Float:Mod and Modulus footer}}
<section begin=dpl_desc />
Remainder of integer division
<section end=dpl_desc />
-->

Latest revision as of 18:02, 2 November 2012

Remainder of integer division (Float class)


The Mod and Modulus 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.

Syntax

%number = float:Mod( divisor)

%number = float:Modulus( divisor)

Syntax terms

%number A variable to receive the integral remainder of the quotient of float / divisor.
float A Float value to be divided by the method argument, divisor.
divisor A non-zero numeric value. A divisor with a value of 0, or a value that rounds down to 0, causes a request cancellation.

Usage notes

  • Mod / Modulus are available as of Sirius Mods Version 7.3.

Examples

  1. 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)

  2. The following statement returns -1 to %z:

    %z = -191.4:mod(2.0)

  3. The following displays the quotient and remainder when dividing 9997 by 7:

    begin %dividend is float %divisor is float %dividend = 9997 %divisor = 7 printtext {~} = {%dividend:div(%divisor)} printText {~} = {%dividend:mod(%divisor)} end

    The result is:

    %dividend:div(%divisor) = 1428 %dividend:mod(%divisor) = 1

See also

  • The Div function returns the integral quotient of a division.