Home > Common Problem > What is the difference between a-- and --a?

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

烟雨青岚
Release: 2020-06-24 16:38:44
Original
42500 people have browsed it

"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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template