Commodore‎ > ‎BASIC‎ > ‎Keywords‎ > ‎

### - (minus)

 Keyword Abbreviation Token (hex) Version(s) Classification - none AB 1.0 to 7.0 Operator (3, subtraction) - none AB 1.0 to 7.0 Operator (2, negation)

minuend subtrahend
~ or ~
minuend

 Parameters Type Legal Value(s) Default Value Note(s) minuend Numeric any subtrahend Numeric any

 Returns Type Value(s) Note(s) difference Numeric any Form 1 negation Numeric any Form 2

 Purpose
Calculate an arithmetic expression.

 Remarks
The minus operator has two simular yet different roles, shown by the two forms of Syntax above.  First it may be used as a subtraction operator to calculate the difference between two numbers (I'm not going to explain how subtraction works).  In this case it has only a medium priority, which is to say, as low as addition (but greater than relational/boolean operators).  Second, the minus operator may be used "alone" to negate an expression (this just reverses the arithmetic sign of minuend).  In this case it has a rather high priorty: the same as multiplication and division, and second only to the power operator.  The user of course may over-ride the built-in operator priorities by using parentheses "(" and ")".

If the absolute value of the result is greater than 1.70141183e+38 then an OVERLOW ERROR occurs.  If the absolute value of the result is less than 2.93873588e-39 then it silently underflows to zero (I'm pretty sure this can only happen when the result really should be zero).

Like all operators, the result may be printed, stored in an appropriate variable, or combined with other functions and operators in a larger expression.  For storing the numeric result into an integer variable the minimum result that can be stored is -32768 and the maximum is +32767; otherwise an ILLEGAL QUANTITY ERROR is generated.

Unlike the plus operator which works with strings too (append operation), the minus operator does not work with strings (no amputate operator).  However BASIC provides at least 3 "string-slicing" functions (see links below).

 Compare With

 Contrast With
*, +