共用方式為


mod

概要

傳回兩個數位除法的餘數。

語法

mod(<operands>)

描述

mod() 式會傳回兩個整數除法的餘數。

範例

範例 1 - 取得兩個整數的餘數

本範例檔示範如何使用 mod() 函式傳回兩個整數除法的餘數。

# mod.example.1.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Remainder for integers
  type: Microsoft.DSC.Debug/Echo
  properties:
  output: "[mod(7, 5)]"
dsc config get --file mod.example.1.dsc.config.yaml config get
results:
- name: Remainder for integers
  type: Microsoft.DSC.Debug/Echo
  result:
    actualState:
      output: 2
messages: []
hadErrors: false

範例 2 - 取得巢狀函式輸出的其餘部分

此組態檔會 mod() 使用 函式來取得其他兩個數學運算輸出的餘數。

# mod.example.2.dsc.config.yaml
$schema: https://aka.ms/dsc/schemas/v3/bundled/config/document.json
resources:
- name: Remainder for nested functions
  type: Microsoft.DSC.Debug/Echo
  properties:
    output: "[mod(add(9, 5), mul(6, 2))]"
dsc config get --file mod.example.2.dsc.config.yaml
results:
- name: Remainder for nested functions
  type: Microsoft.DSC.Debug/Echo
  result:
    actualState:
      output: 2
messages: []
hadErrors: false

參數

運算元

mod() 式預期只有兩個整數做為輸入。 操作數可以是整數或傳回整數之任何組態函式的輸出。 函式會將第一個操作數除以第二個操作數。 以逗號分隔 操作 數 (,) 。

Type:         integer
Required:     true
MinimumCount: 2
MaximumCount: 2

輸出

函式會傳回整數,代表 操作數除法運算的其餘部分。

Type: integer