Skip to main content

Division (/)

Divides two numerically operands, after interpreting both operands as numbers.

Details

The Division operator produces the result of dividing two numerically interpreted operands. It uses any leading numeric characters as the numeric value of the operands and products a result that is the quotient.

Examples

The following example performs division on two numeric literals:

 WRITE 9 / 5.5 // 1.636363636363636364

The following example performs division on two locally defined variables:

 SET x = 4
 SET y = 5
 WRITE x / y // .8

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

 WRITE "8 apples" / "4 oranges"  // 2

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

 WRITE "eight apples" / "4 oranges" // 0
 // "8 apples"/"four oranges" generates a <DIVIDE> error

Note that the second of these operations is invalid. Dividing a number by zero is not allowed. ObjectScript returns a <DIVIDE> error message.

FeedbackOpens in a new tab