Bitmanipulation für Anfänger: Difference between revisions
Jump to navigation
Jump to search
Line 12: | Line 12: | ||
** 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>wir meinen 32-Bit Integer, 8-, 16- und 64-Bit-Integer lassen wir mal weg :)</ref> | * 1 ''Integer''<ref>wir meinen Signed-32-Bit Integer, 8-, 16- und 64-Bit-Integer und unsigned 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 |
Revision as of 18:15, 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
- Beispiel: 1
- 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:
- Integer und andere ordinale Typen in FreePascal (=Lazarus=Delphi): http://www.freepascal.org/docs-html/ref/refsu5.html
- Integer in Wikipedia: http://de.wikipedia.org/wiki/Integer_(Datentyp)
- Fußnoten: