摘要
返回两个数字除法的余数。
语法
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