次の方法で共有


mod

概要

2 つの数値の除算の剰余を返します。

構文

mod(<operands>)

説明

関数は mod() 、2 つの整数の除算の剰余を返します。

例 1 - 2 つの整数の剰余を取得する

このドキュメントの例では、 関数を mod() 使用して、2 つの整数の除算の残りの部分を返す方法を示します。

# mod.example.1.dsc.config.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Remainder for integers
  type: Test/Echo
  properties:
  output: "[mod(7, 5)]"
dsc config get --document mod.example.1.dsc.config.yaml config get
results:
- name: Remainder for integers
  type: Test/Echo
  result:
    actualState:
      output: 2
messages: []
hadErrors: false

例 2 - 入れ子になった関数の出力の剰余を取得する

この構成ドキュメントでは、 関数を mod() 使用して、他の 2 つの算術演算の出力を調べる剰余を取得します。

# mod.example.2.dsc.config.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Remainder for nested functions
  type: Test/Echo
  properties:
    output: "[mod(add(9, 5), mul(6, 2))]"
dsc config get --document mod.example.2.dsc.config.yaml
results:
- name: Remainder for nested functions
  type: Test/Echo
  result:
    actualState:
      output: 2
messages: []
hadErrors: false

パラメーター

オペランド

関数では mod() 、入力として 2 つの整数が必要です。 オペランドには、整数または整数を返す任意の構成関数の出力を指定できます。 関数は、最初のオペランドを 2 番目のオペランドで除算します。 オペランドをコンマ (,) で区切ります。

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

出力

関数は、オペランドの除算演算の残りの部分を表す整数を返 します

Type: integer