Subtraction Operator (-)

Source: Internet
Author: User
Tags expression numeric numeric value string
Operation

Subtracts the value of one expression from the value of another, with only one expression taking the opposite number.

Syntax 1

result = number1 - number2

Syntax 2

-number

Parameters

Result

Any numeric variable .

Number

Any numeric expression .

Number1

Any numeric expression.

Number2

Any numeric expression.

Description

In Syntax 1, the- operator is the arithmetic subtraction operator, which is used to get the difference between two values. In Syntax 2, the- operator is used as a unary negative operator to indicate the negative value of an expression.

For Syntax 2, as with all unary operators, an expression is evaluated according to the following rules:

    • If applied to an undefined or null expression, a run-time error is generated.
    • object is converted to a string.
    • If possible, the string is converted to a numeric value. If not, a run-time error is generated.
    • The Boolean value is treated as a numeric value (0 if False, or 1 if true).

The operator is used to produce a numeric value. In Syntax 2, if the generated value is not 0, then result is equal to the value that is generated by reversing the symbol. If the generated value is zero, then result is zero.

Requirements

Version 1

Please see

- = operator | Operator Precedence | Operator Summary



Related Article

Alibaba Cloud 10 Year Anniversary

With You, We are Shaping a Digital World, 2009-2019

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.