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



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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.