Simple Processing: Multiplication and Division operators

The multiplication and division operators are very similar. Both can only be used with numeric items and both perform their mathematical functions. That is the value on the left hand side of the operator is multiplied or divided by the value on the right hand side.

Both operators can be used in the shortcut mode (the result of the calculation cannot be used in another expression or as a parameter to a command and the item on the left hand side of the operator must be a variable). In the shortcut mode the variable on the left hand side of the operator will be multiplied or divided by the value on the right hand side, with the result being stored in the variable on the left hand side of the operator. These lines illustrate the point and equivalent:

a = a * b
a * b

c = c / d
c / d
The example below shows some uses of the multiplication and division operators. You can also get the source here.
OpenConsole()

width.l = 3
length.l = 2
height.l = 2

area.l = width * length
volume.l = height * area
volume2.l = width * length * height
PrintN("Plan view area = "+Str(area))
PrintN("Volume = "+Str(volume)+" and should be the same as Volume2 = "+Str(volume2))

total_cost.f = 13.67
quantity.l = 9
price_each.f = total_cost / quantity
price_each / 1.175
PrintN("Price of each item (excluding UK VAT) = "+StrF(price_each))

PrintN("Press return to exit")
Input()
CloseConsole()
End

Output of the multiplication and division example This image shows the output of the above example program.