Mod and Modulus (Float functions): Difference between revisions

From m204wiki
Jump to navigation Jump to search
m (syntax terms)
m (1 revision)
(No difference)

Revision as of 17:46, 4 May 2011

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

    so displays:

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

See also

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