Operator _ and _ operator priority

Source: Internet
Author: User

Mathematical operators (7 ):

+,-, *,/, %, ++, And ,--

1 · % is the remainder operator, for example: 3% 2 = 1 8% 3 = 2

2. ++ and -- are the auto-increment 1 and auto-increment 1 operators.

3. I ++ and I both add 1 operations. For example, I ++ and ++ I are equal to I = I + 1 (I = I ++ and I = ++ I have different meanings than I ++ and I + I, (it can be understood that the plus sign first adds the 1 operation and then the value assignment, and the plus sign first adds the value to the 1 operation. For example, int I = 6; I = ++ I; the result is 7, I = I ++; the result is 6 .))

 

Relational operators:

= ,! =, <,>, <=,> =

 

Logical operators (common and boolean operators ):

& (Logical and), | (logical or ),! (Non-logical)

&: True only when all conditions are met.

|: True if one condition is met.

! : The highest level in logical operators.

 

Conditional OPERATOR :? :

Int I;

String S = (relational operation )? (1) :( 2 );

(If the conditions are met, output within 1 bracket; if the conditions are not met, output within 2 brackets)

 

Computing priority [from top to bottom]

!

(Arithmetic operation level)

++, -- (Prefix)

*,/, %

+ ,-

(Relational operators)

<,>, <=,> =

= ,! =

(Logical operators)

&&

|

! : The highest level in logical operators.

 

Computing priority example

Int I = 5;

Int S = int. parse (console. Readline (); // The keyboard accepts integer S.

Bool B =! (S> 5) & (S> = (1 + 2*3-(I ++ )));

Bool B =! (S> 5) & (S> = (1 + 2*3-(-- I )));
Bool B =! (S> 5) & amp; S> = 1 + 2*3--- I;

Bool B =! (S> 5) & amp; S> = 1 + 2*3-(-- I)/2;

 

Operator _ and _ operator priority

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.