Subtraction (-)
Last updated
Was this helpful?
Last updated
Was this helpful?
Airkit supports the standard subtraction operator -
. It is used to subtract values from other Numbers and values from other Currencies.
The following example shows how the subtraction operator is used to subtract the Number 2 from the Number 3. Note that it returns a another Number: 1, 2 less than 3:
The subtraction operator can be used to subtract Currencies provided the Currency values have the same currency code. For instance, say you have two Currency values, currency_1
and currency_2
, defined as follows:
currency_1
and currency_2
both represent money in US dollars, so one can be subtracted by the other using the subtraction operator:
Airscript supports negative Currency values, so it is also possible to use the subtraction operator to subtract currency_1
from currency_2
, as follows. Note that the resulting Currency has a negative amount value:
Currency values cannot be subtracted if they do not have matching currency codes. For example, say there is a third Currency value, currency_3
, in Euros rather than dollars, defined as follows:
Attempting to use the subtraction operator to subtract currency_3
from currency_1
will result in an error, because the subtraction operator cannot subtract euros from US dollars: