次の方法で共有


div

概要

2 つの整数の除算の商を返します。

構文

div(<operands>)

説明

関数は div() 、2 つの整数の除算の商を返します。 除算の結果が整数でない場合、関数は最も近い整数に切り捨てた除算の値を返します。

例 1 - 2 つの整数を除算する

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

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

例 2 - 入れ子になった関数の出力を分割する

このドキュメントの例では、 関数を div() 使用して、入れ子になった構成関数の出力を分割する方法を示します。 出力は 14 と 5 であるため、最終的な結果は 2 です。 DSC は、剰余なしで完全な整数値を返します。 結果は 3 に切り上げられません。

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

パラメーター

オペランド

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

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

出力

関数は div() 、2 番目のオペランドによる最初のオペランドの除算を表す整数値を返します。 除算結果が整数でない場合、関数は小数部の剰余なしで結果の整数値を返します。

Type: integer