Numeric systems 
Top Previous Next 
Glossary > Numeric systems
We are used to specify integer numbers by 10 different digits. Computers however only know 0 and 1. For example the number 156 of our decimal system expressed in the binary computer format is
10011100
Because such binary numbers can be transformed to octal and hexadecimal representations very easily, the c++ language has conventions for representing octal and hexadecimal values. Leading zeros are used to signal an octal constant and starting a number with "0x" indicates a hexadecimal constant. The transformation of the binary value above into an octal number is done by separating the binary value in groups of 3 numbers and than replacing these group according to the table below:
10 011 100
2 3 4
In c++ the resulting octal number is written in c++ as: 0235
The procedure of converting the binary number into a hexadecimal representation is analogously, but you have to separate the digits into groups of four digits this time:
1001 1100
9 C
In c++ the resulting hexadecimal number is written in c++ as: 0x9C
Escape sequences are a similar representation of characters by octal numbers or hexadecimal numbers.

This page belongs to the TextTransformer Documentation 
Home Content German 