Bitmanipulation für Anfänger: Difference between revisions
Jump to navigation
Jump to search
Line 11: | Line 11: | ||
** Beispiel: <tt>1 0 0 0 0 0 0 1</tt> ist der Wert 129 | ** Beispiel: <tt>1 0 0 0 0 0 0 1</tt> ist der Wert 129 | ||
** Beispiel: <tt>1 1 1 1 1 1 1 1</tt> ist der Wert 255 | ** Beispiel: <tt>1 1 1 1 1 1 1 1</tt> ist der Wert 255 | ||
* 1 Integer<ref>32-Bit Integer, 16-Bit-Integer lassen wir mal weg :)</ref> | * 1 Integer<ref>wir meinen 32-Bit Integer, 8-, 16- und 64-Bit-Integer lassen wir mal weg :)</ref> | ||
** hat 4 Byte (32 Bit) | ** hat 4 Byte (32 Bit) | ||
** kann 4.294.967.296 Werte annehmen: −2.147.483.648 bis 2.147.483.647 | ** kann 4.294.967.296 Werte annehmen: −2.147.483.648 bis 2.147.483.647 | ||
** Beispiel: <tt>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</tt> ist der Wert 0 | |||
** Beispiel: <tt>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1</tt> ist der Wert 1 | |||
** Beispiel: <tt>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1</tt> ist der Wert 256 | |||
** Beispiel: <tt>0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</tt> ist der Wert 65.536 | |||
** Beispiel: <tt>0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0</tt> ist der Wert 16.777.216 | |||
** Beispiel: <tt>0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1</tt> ist der Wert 2.147.483.647 | |||
<!-- ** Beispiel: <tt>1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1</tt> ist der Wert −2.147.483.648 (Das vorderste Bit (Das MSB) ist das Vorzeichen-Bit!) --> | |||
==== Über die Bits eines Bytes oder Integers ==== | ==== Über die Bits eines Bytes oder Integers ==== |
Revision as of 18:11, 9 June 2013
Von Bits und Bytes
Daten-Typen (Variablen-Typen)
- 1 Bit ist die kleinste Einheit
- 1 Bit kann nur 2 Werte annehmen: 0 oder 1 (false oder true)
- Beispiel: <0>
- 1 Byte...
- ...hat 8 Bit
- ein Byte kann 256 (2 hoch 7) Werte annehmen: 0 bis 255
- Beispiel: 0 0 0 0 0 0 0 0 ist der Wert 0
- Beispiel: 1 0 0 0 0 0 0 0 ist der Wert 128
- Beispiel: 1 0 0 0 0 0 0 1 ist der Wert 129
- Beispiel: 1 1 1 1 1 1 1 1 ist der Wert 255
- 1 Integer[1]
- hat 4 Byte (32 Bit)
- kann 4.294.967.296 Werte annehmen: −2.147.483.648 bis 2.147.483.647
- Beispiel: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ist der Wert 0
- Beispiel: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 ist der Wert 1
- Beispiel: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 1 ist der Wert 256
- Beispiel: 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ist der Wert 65.536
- Beispiel: 0 0 0 0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ist der Wert 16.777.216
- Beispiel: 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 ist der Wert 2.147.483.647
Über die Bits eines Bytes oder Integers
- Das rechteste Bit eines Bytes oder Integer nennt man das LeastSignificantBit[2].
- Das rechteste Bit eines Bytes oder Integer nennt man das MostSignificantBit[3].
- Links:
- Fußnoten: