通过


Number.Mod

Syntax

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

About

返回由整数除 numberdivisor产生的余数。 如果 numberdivisornull,则此函数返回 null

示例 1

将 5 除以 3 时查找余数。

用法

Number.Mod(5, 3)

输出

2

示例 2

将 10.5 除以 0.2,使用 Double 精度和 Decimal 精度来查找余数。

用法

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"

输出

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