I haven't updated it after a long time, because I am learning about PL and compiler interpreters. I'm curious about this. because I haven't learned any relevant courses, I have to learn a little hard work and slow progress, so I have nothing to write. Today, we can see that the 32-bit int type ranges from 2147483647 to-2147483648. However, in the CC ++ language, you cannot directly use-2147483648 to replace the minimum negative number,
I haven't updated it after a long time, because I am learning PL and compiler/interpreter knowledge. I'm curious about this. because I haven't learned any relevant courses, I have to learn a little hard work and slow progress, so I have nothing to write.
Today, we see a passage like this:
The value of 32-bit int type is 2147483647 to-2147483648. However, in C/C ++, you cannot directly use-2147483648 to replace the minimum negative number, because it is not a number, but an expression. The expression is: "negative for positive number 2147483648". Therefore, 2147483648 has exceeded. This is why INT_MIN is always defined as (-INT_MAX-1.
I have never paid attention to this before. in the spirit of practice, I ran it on my computer and found that the results were all the same. there was no warning when I started the Wall with gcc. So what is the problem?
Later, a former MSRA employee told me:
In fact, it depends on the standard version ...... If the type of decimal literal is C8 (harmonious) 9, the inferred sequence of decimal literal is long and unsigned long. Therefore, the literal of-21474836 (harmonious) 48 is interpreted as unsigned long, therefore, if it is C ++ 11, it is inferred that the order is long, and long is no problem.
Amount, and the basic knowledge is forgotten.