Arithmetic¶
Decision includes some basic arithmetic operators by default.
Addition¶
You can add at least two numbers together:
Start~#1
Add(5, 6)~#2
Print(#1, #2)~#3
Add(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)~#4
Print(#3, #4)
$ decision addition.dc
11
55
Subtraction¶
You can subtract two numbers:
Start~#1
Subtract(12.63, 5.82)~#2
Print(#1, #2)
$ decision subtract.dc
6.81
Multiplication¶
You can multiply at least two numbers together:
Start~#1
Multiply(5.5, 10)~#2
Print(#1, #2)~#3
Multiply(1, 2, 3, 4, 5)~#4
Print(#3, #4)
$ decision multiply.dc
55
120
Division¶
You can divide two numbers:
Start~#1
Divide(4, 2)~#2
Print(#1, #2)~#3
Divide(10, 3)~#4
Print(#3, #4)
$ decision division.dc
2
3.33333
Integer Division¶
You can divide two numbers and truncate the result to get an integer:
Start~#1
Div(4, 2)~#2
Print(#1, #2)~#3
Div(10, 3)~#4
Print(#3, #4)
$ decision div.dc
2
3
Modulo¶
You can take the remainder after division of two integers:
Start~#1
Mod(4, 2)~#2
Print(#1, #2)~#3
Mod(10, 3)~#4
Print(#3, #4)
$ decision mod.dc
0
1