के माध्यम से साझा करें


Number.Mod

Syntax

Number.Mod(
    number as nullable number,
    divisor as nullable number,
    optional precision as nullable number
) as nullable number

About

Returns the remainder resulting from the integer division of number by divisor. If number or divisor are null, this function returns null.

  • number: The dividend.
  • divisor: The divisor.
  • precision: (Optional) The precision of the integer division. This parameter can be either Precision.Double for Double precision or Precision.Decimal for Decimal precision. The default value is Precision.Double.

Example 1

Find the remainder when you divide 5 by 3.

Usage

Number.Mod(5, 3)

Output

2

Example 2

Find the remainder when you divide 10.5 by 0.2, using both Double precision and Decimal precision.

Usage

let
    Dividend = 10.5,
    Divisor = 0.2,

    #"Use Double Precision" = Number.Mod(Dividend, Divisor, Precision.Double),
    #"Use Decimal Precision" = Number.Mod(Dividend, Divisor, Precision.Decimal),

    // Convert to text to inspect precision
    #"Double To Text" = Number.ToText(#"Use Double Precision", "G"),
    #"Decimal To Text" = Number.ToText(#"Use Decimal Precision", "G"),
    
    #"Display Result" = [
        DoublePrecision = #"Double To Text",
        DecimalPrecision = #"Decimal To Text"
    ]

in
    #"Display Result"

Output

[
    DoublePrecision = "0.0999999999999994",
    DecimalPrecision = "0.1"
]