C/C ++ Expression of the octal number in
1Expression of the. octal number
C/C ++How does one express an octal number in a language? If the number is876,We can conclude that it is not an octal number, because it is impossible to generate7The Arabic numerals above. But if the number is123Yes567, Or12345670Is it octal or10The number of hexadecimal values is possible.
So, C/C ++Rules,If you want to specify that a number uses an octal value, you must add0Such:123It is in decimal format,0123It indicates that octal is used. This is where the number of octal nodes isC,C ++.
BecauseCAndC ++No way to express the binary numberSo we learned the octal chart here,C,C ++The second method of expressing the value of a language.
Now, for the same number, for example100InCodeCommon10Hexadecimal representation, for example, during variable initialization:
Int A = 100;
We can also write:
Int A = 0144; // 0144It's octal.100; One10How to convert hexadecimal numbers8In hexadecimal notation, we will learn later.
Remember, when expressed in octal,You cannot lose the first one.0. Otherwise, the computer will communicate10Base. However, when the number of octal nodes is used, the addition cannot be used.0That is the "Escape Character" expression we learned before for expressing characters.
2 . Use of Octal numbers in escape characters
We have learned to use an escape character'/'Add a special letter to indicate a character, for example:'/N'Line feed(Line), And'/T'IndicatesTabCharacter,'/''Single quotes. Today, we learned another method to use escape characters: escape characters'/'Followed by an octal number, used to representASCIIThe character whose code is equal to the value.
For example, checkASCIICode table, We find the question mark character (?)OfASCIIThe value is63So we can convert it to an octal value:77And then use'/77'To indicate'? '. Because it is octal, it should be written'/077'But becauseC/C ++Slash addition is not allowed.10In hexadecimal notation0You can leave it empty.
In fact, we seldom use escape characters and Octal numbers to represent a character in actual programming. However, we need to know it later.