Function Math Reals Class

ModStd

"Modulo (Standard Definition)" or "Modulus" or "Remainder" Floating-point modulus of real numbers.

Signature (Visual Basic / VBA)

Public Function ModStd( _
      ByVal vX As Variant _
    , ByVal vY As Variant _
    ) As Variant

Code Examples

    ModStd(0, 3) = 0
    ModStd(1, 3) = 1
    ModStd(2, 3) = 2
    ModStd(3, 3) = 0
    ModStd(4, 3) = 1
    ModStd(-1, 3) = -1
    ModStd(-2, 3) = -2
    ModStd(-2, -3) = -2
    ModStd(2, -3) = 2
    Y = 4 or Y = -4:
               |  *   *   *
               | *   *   *
               |*   *   *
    ---*---*---*---*---*---
      *   *   *|
     *   *   * |
    *   *   *  |
    X - Y * Fix(X / Y)

Parameters

Parameter Description
vX See the Definition. Function returns Null if vX is Null or cannot be fixed up to a number.
vY See the Definition. Function returns Null if vY is Null or cannot be fixed up to a number.

Notes & Version History

Note Differs from the ModAlt function when X is negative and Y is positive. We believe that the other definition of the modulo function in ModAlt is much more widely accepted than this definition (ModStd is similar to the definition that Microsoft implements in all of their language products).
v1.2 BugFix Changed the above sentence from "... function in ModStd is much ...." to "... function in ModAlt is much ...."