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