共用方式為


mul

概要

傳回乘兩個整數的乘積。

語法

mul(<operands>)

描述

函式會 mul() 傳回乘兩個整數的乘積。 它會將第一個操作數乘以第二個操作數。 您可以巢狀呼叫 來 mul() 相乘兩個以上的整數。

範例

範例 1 - 將兩個整數相乘

本範例檔會乘以兩個整數,以傳回輸出的產品。

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

範例 2 - 將巢狀函式的輸出相乘

本文件說明如何將巢狀組態函式的輸出相乘。

# mul.example.2.dsc.config.yaml
$schema: https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2024/04/config/document.json
resources:
- name: Multiplying nested function outputs
  type: Test/Echo
  properties:
    output: "[mul(add(3, 2), div(12, 4))]"
dsc config get --document mul.example.2.dsc.config.yaml
results:
- name: Multiplying nested function outputs
  type: Test/Echo
  result:
    actualState:
      output: 15
messages: []
hadErrors: false

參數

運算元

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

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

輸出

函式會 mul() 傳回整數,代表乘數 操作數的乘積。

Type: integer