Skip to main content

Subtraction (-)

Produces the numeric difference between two operands, after interpreting them as numbers.


The Subtraction operator produces the difference between two numerically interpreted operands. It interprets any leading, valid numeric characters as the numeric values of the operand and produces a value that is the remainder after subtraction.


The following example performs subtraction on two numeric literals:

 WRITE 2936.22 - 301.45 // 2634.77

The following example performs subtraction on two locally defined variables:

 SET x = 4
 SET y = 5
 WRITE "x - y = ",x - y // -1

The following example performs string arithmetic on two operands that have leading digits, subtracting the resulting numerics:

 WRITE "8 apples" - "4 oranges" // 4

If the operand has no leading numeric characters, ObjectScript assumes its value to be zero. For example:

 WRITE "8 apples" - "four oranges" // 8
FeedbackOpens in a new tab