แชร์ผ่าน


Number.Mod

วากยสัมพันธ์

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

ประมาณ

ส่งกลับผลลัพธ์ที่เหลือจากการหารจํานวนเต็มของ number โดย divisor ถ้า number หรือ divisor เป็น nullฟังก์ชันนี้ส่งคืนnull

  • number: ตัวตั้ง
  • divisor: ตัวหาร
  • precision: (ไม่บังคับ) ความแม่นยําของการหารจํานวนเต็ม พารามิเตอร์นี้สามารถเป็นได้ทั้ง Precision.Double สําหรับ Double ความแม่นยําหรือ Precision.Decimal สําหรับ Decimal ความแม่นยํา ค่าเริ่มต้นคือ Precision.Double

ตัวอย่างที่ 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"
]