Zahlensysteme-Spickzettel (Dezimal / Hexadezimal / Binär)
Im Code wird Hexadezimal meist mit 0x und Binär mit 0b geschrieben.
| Dezimal | Hexadezimal | Binär |
|---|---|---|
| 0 | 0x0 | 0b0 |
| 1 | 0x1 | 0b1 |
| 2 | 0x2 | 0b10 |
| 3 | 0x3 | 0b11 |
| 4 | 0x4 | 0b100 |
| 5 | 0x5 | 0b101 |
| 6 | 0x6 | 0b110 |
| 7 | 0x7 | 0b111 |
| 8 | 0x8 | 0b1000 |
| 9 | 0x9 | 0b1001 |
| 10 | 0xA | 0b1010 |
| 11 | 0xB | 0b1011 |
| 12 | 0xC | 0b1100 |
| 13 | 0xD | 0b1101 |
| 14 | 0xE | 0b1110 |
| 15 | 0xF | 0b1111 |
| 16 | 0x10 | 0b10000 |
| 17 | 0x11 | 0b10001 |
| 18 | 0x12 | 0b10010 |
| 19 | 0x13 | 0b10011 |
| 20 | 0x14 | 0b10100 |
| 21 | 0x15 | 0b10101 |
| 22 | 0x16 | 0b10110 |
| 23 | 0x17 | 0b10111 |
| 24 | 0x18 | 0b11000 |
| 25 | 0x19 | 0b11001 |
| 26 | 0x1A | 0b11010 |
| 27 | 0x1B | 0b11011 |
| 28 | 0x1C | 0b11100 |
| 29 | 0x1D | 0b11101 |
| 30 | 0x1E | 0b11110 |
| 31 | 0x1F | 0b11111 |
| 32 | 0x20 | 0b100000 |
Hinweise
- 1 Hexadezimalziffer = 4 Bit; 2 Hexadezimalziffern = 1 Byte.
- Negative Zahlen im Zweierkomplement sind ein eigenes Thema.
Häufige Fragen
- Wie lautet 32 in Hexadezimal und Binär?
- Die Dezimalzahl 32 ist 0x20 in Hexadezimal und 0b100000 in Binär. Hexadezimalziffern über 9 verwenden die Buchstaben A–F für die Werte 10–15.
- Wie viele Bits repräsentiert eine Hexadezimalziffer?
- Eine Hexadezimalziffer steht für genau 4 Bits, zwei Ziffern ergeben also ein Byte (8 Bits). Deshalb passt Hexadezimal so sauber auf Binär.
- Was bedeutet das Präfix 0x in der Programmierung?
- 0x kennzeichnet ein Literal als hexadezimal: 0x10 entspricht 16 im Dezimalsystem. Binärliterale nutzen das Präfix 0b, etwa 0b1010 = 10.