Nota
El acceso a esta página requiere autorización. Puede intentar iniciar sesión o cambiar directorios.
El acceso a esta página requiere autorización. Puede intentar cambiar los directorios.
数值运算符使用整数执行计算并返回整数值。 若要运行示例,请使用 Azure CLI 或 Azure PowerShell 部署 Bicep 文件。
Nota
减去和减号使用相同的运算符。 功能不同,因为减法使用两个作数,减法使用一个作数。
operand1 * operand2
将两个整数相乘。
操作数 | 类型 | DESCRIPTION |
---|---|---|
operand1 |
整数 | 要相乘的数字。 |
operand2 |
整数 | 数字的乘数。 |
乘法将乘积作为整数返回。
两个整数相乘并返回乘积。
param firstInt int = 5
param secondInt int = 2
output product int = firstInt * secondInt
示例中的输出:
名称 | 类型 | 价值 |
---|---|---|
product |
整数 | 10 |
operand1 / operand2
将整数除以整数。
操作数 | 类型 | DESCRIPTION |
---|---|---|
operand1 |
整数 | 除法的整数。 |
operand2 |
整数 | 用于除法的整数。 不能为零。 |
除法将商作为整数返回。
两个整数被除以并返回商。
param firstInt int = 10
param secondInt int = 2
output quotient int = firstInt / secondInt
示例中的输出:
名称 | 类型 | 价值 |
---|---|---|
quotient |
整数 | 5 |
operand1 % operand2
将整数除以整数并返回余数。
操作数 | 类型 | DESCRIPTION |
---|---|---|
operand1 |
整数 | 被除的整数。 |
operand2 |
整数 | 用于除法的整数。 不能为 0。 |
余数以整数的形式返回。 如果除法不生成余数,则返回 0。
两对整数被除以并返回余数。
param firstInt int = 10
param secondInt int = 3
param thirdInt int = 8
param fourthInt int = 4
output remainder int = firstInt % secondInt
output zeroRemainder int = thirdInt % fourthInt
示例中的输出:
名称 | 类型 | 价值 |
---|---|---|
remainder |
整数 | 1 |
zeroRemainder |
整数 | 0 |
operand1 + operand2
添加两个整数。
操作数 | 类型 | DESCRIPTION |
---|---|---|
operand1 |
整数 | 要添加的数字。 |
operand2 |
整数 | 添加到数字的数字。 |
加法将求和作为整数返回。
添加两个整数并返回总和。
param firstInt int = 10
param secondInt int = 2
output sum int = firstInt + secondInt
示例中的输出:
名称 | 类型 | 价值 |
---|---|---|
sum |
整数 | 12 |
operand1 - operand2
从整数中减去整数。
操作数 | 类型 | DESCRIPTION |
---|---|---|
operand1 |
整数 | 从中减去的较大数字。 |
operand2 |
整数 | 从较大的数字中减去的数字。 |
减法以整数的形式返回差值。
一个整数被减去并返回差异。
param firstInt int = 10
param secondInt int = 4
output difference int = firstInt - secondInt
示例中的输出:
名称 | 类型 | 价值 |
---|---|---|
difference |
整数 | 6 |
-integerValue
将整数乘以 -1
。
操作数 | 类型 | DESCRIPTION |
---|---|---|
integerValue |
整数 | 整数乘以 -1 。 |
整数乘以 -1
。 正整数返回负整数,负整数返回正整数。 这些值可以用括号包装。
param posInt int = 10
param negInt int = -20
output startedPositive int = -posInt
output startedNegative int = -(negInt)
示例中的输出:
名称 | 类型 | 价值 |
---|---|---|
startedPositive |
整数 | -10 |
startedNegative |
整数 | 20 |
- 若要创建 Bicep 文件,请参阅快速入门:使用 Visual Studio Code 创建 Bicep 文件。
- 有关如何解决 Bicep 类型错误的信息,请参阅 Bicep 的 Any 函数。
- 若要比较 Bicep 和 JSON 的语法,请参阅比较模板的 JSON 和 Bicep。
- 有关 Bicep 函数的示例,请参阅 Bicep 函数。