Skip to content

Math.Multiply

Name Mandatory Description Default Type
⬅️ Input The value or the sequence of values to multiply the value specified in the Operand parameter with. IntInt2Int3Int4Int8Int16FloatFloat2Float3Float4Color[Any]
Output ➡️ This shard outputs the result of the multiplication. IntInt2Int3Int4Int8Int16FloatFloat2Float3Float4Color[Any]
Operand No The value or sequence of values to multiply the input by. 0 IntVar(Int)Int2Var(Int2)Int3Var(Int3)Int4Var(Int4)Int8Var(Int8)Int16Var(Int16)FloatVar(Float)Float2Var(Float2)Float3Var(Float3)Float4Var(Float4)ColorVar(Color)[Any]Var([Any])

This shard multiplies the input value by the value provided in the Operand parameter.

Details

This shard can take an integer or a sequence of integers as input. However, depending on the type of input, the appropriate Operand needs to be provided:

For non-sequence inputs: The Operand must match the input type exactly (e.g., Int2 with Int2, Color with Color).

For sequence inputs: The Operand can be either: - A matching non-sequence type (e.g., sequence of Int2 with a single Int2 Operand). Each element of the input sequence is operated on by the Operand. - Another sequence of elements with the same types. Each element of the Operand sequence is applied to the corresponding element of the input sequence. If the input sequence is longer, the Operand sequence will loop over till all elements of the input sequence are operated on. If the Operand sequence is longer, the extra elements of the Operand sequence are ignored.

Examples

1
2
3
4
5
6
7
8
; Multiply unequal-sized sequences (input size < operand size)
[4.0] ; Input
Log ; prints input => [4.0]
Math.Multiply([3.0 4.0 2.2]) ; Operand
; input seq elements compute with corresponding operand seq elements
; since input size < operand size, remaining operand seq elements ignored
Log ; prints input * operand => [12.0]
Assert.Is([12.0] true) ; expect: [(4.0 * 3.0) ... ...] => [12.0]


 

1
2
3
4
5
6
7
8
; Multiply unequal-sized sequences (input size > operand size)
[4 2 1 5 8] ; Input
Log ; prints input => [4 2 1 5 8]
Math.Multiply([6 4]) ; Operand
; input seq elements compute with corresponding operand seq elements
; for (input size > operand size): remaining input seq elements continually loop over operand seq elements
Log ; prints input + operand => [24 8 6 20 48]
Assert.Is([24 8 6 20 48] true) ; expect: [(4 * 6) (2 * 4) (1 * 6) (5 * 4) (8 * 6)] => [24 8 6 20 48]


 

1
2
3
4
5
6
; Multiply floats
5.3 ; Input
Log ; prints input => 5.3
Math.Multiply(2.1) ; Operand
Log ; prints input * operand => 11.13
Assert.Is(11.13 true) ; expect: (5.3 * 2.1) => 11.13


 

1
2
3
4
5
6
7
; Multiply equal-sized sequences
[4 5.1 6.4] ; Input
Log ; prints input => [4 5.1 6.4]
Math.Multiply([3 4.0 2.2]) ; Operand
; input seq elements compute with corresponding operand seq elements
Log ; prints input * operand => [12 20.4 14.08]
Assert.IsAlmost([12 20.4 14.08]) ; expect: [(4 * 3) (5.1 * 4.0) (6.4 * 2.2)] => [12 20.4 14.08]


 

1
2
3
4
5
6
; Multiply integers
5 ; Input
Log ; prints input => 5
Math.Multiply(2) ; Operand
Log ; prints input * operand => 10
Assert.Is(10 true) ; expect: (5 * 2) => 10