Home  >  Article  >  What is the difference between a-- and --a?

What is the difference between a-- and --a?

烟雨青岚
烟雨青岚Original
2020-06-24 16:38:4442449browse

"a--" means quoting first and then decrementing. First use the current value of a in the expression where a is located, and then decrement a by 1; "--a" means decrementing first and then quoting, letting a First subtract 1, and then use the new value of a in the expression where a is.

What is the difference between a-- and --a?

The difference between a-- and --a is:

a-- is quoted first Then reduce, first use the current value of a in the expression where a is located, and then decrement a by 1

--a is first reduced and then referenced, decrement a by 1 first, and then Use the new value of a in the expression where a is located

They actually all mean a=a-1, but the order of execution is different when running in the program.

The difference between a and --a:

1. Different operation results

1. a: The operation result is the result of the expression a plus One person.

2. --a: The operation result is the result of expression a minus one digit.

What is the difference between a-- and --a?

2. Different operation processes

1. a: During the operation process, the a expression is executed first, and then the auto-increment operation is executed.

2. --a: During the operation, the auto-decrement operation is performed first, and then the a expression is run.

3. Different memory operations

1. a: Run a in the memory first, and then add 1 to the register.

2. --a: The register in the memory is subtracted by 1 first, and then the a expression is executed.

For more related knowledge, please visit PHP Chinese website! !

The above is the detailed content of What is the difference between a-- and --a?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Related articles

See more