description | ms.date | ms.topic | title |
---|---|---|---|
Reference for the 'mod' DSC configuration document function |
03/19/2024 |
reference |
mod |
Returns the remainder for the division of two numbers.
mod(<operands>)
The mod()
function returns the remainder for the division of two integers.
This example document shows how you can use the mod()
function to return the remainder of a
division for two integers.
# 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
This configuration document uses the mod()
function to get the remainder for diving the output of
two other mathematical operations.
# 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
The mod()
function expects exactly two integers as input. The operands can be either an
integer or the output of any configuration function that returns an integer. The function divides
the first operand by the second operand. Separate the operands with a comma (,
).
Type: integer
Required: true
MinimumCount: 2
MaximumCount: 2
The function returns an integer representing the remainder of the division operation for the operands.
Type: integer