Für die Speicherung von Integer und Floating Point Variablen gibt es unterschiedliche Formate und Größen. Ein weiterer Unterschied ist die Reihenfolge der Bytes bei der Ablage im Speicher des Rechners. Beim Big Endian Format, welches von Motorola CPU's benutzt wird, wird zuerst das höherwertige Byte gespeichert und zuletzt das niederwertigste Byte. Beim Little Endian Format, welche von Intel CPU's benutzt wird, ist es genau umgekehrt. Zuerst wird das niederwertigste Byte und zuletzt das höherwertige Byte gespeichert.
Big Endian Format (Motorola 680x0) $1234ABCD interne Darstellung
Little Endian Format (Intel x86) $CDAB3412 interne Darstellung
Im folgenden sind einige Pascal Funktionen angegeben, mit denen zwischen die Formate umgewandelt werden können:
Umwandlung für Word und Integer:
Function SwapInt(i1:Integer):Integer;
Begin
Result := Swap(i1);
End;
Umwandlung für dWord und LongInt:
Function SwapLong(i1:Integer):Integer;
Type PArray = Array [0..3] of Byte;
Var Tmp: ^PArray; it: Byte; i:Integer;
Begin
Tmp := @i1;
For i := 0 to 1 do Begin
it := Tmp^[i];
Tmp^[i] := Tmp^[3-i];
Tmp^[3-i] := it;
End;
Result := i1;
End;
Umwandlung für Single:
Function SwapSingle(i1:Single):Single;
Type PArray = Array [0..3] of Byte;
Var Tmp: ^PArray; it: Byte; i:Integer;
Begin
Tmp := @i1;
For i := 0 to 1 do Begin
it := Tmp^[i];
Tmp^[i] := Tmp^[3-i];
Tmp^[3-i] := it;
End;
Result := i1;
End;
Umwandlung für Double:
Function SwapDouble(i1:Double):Double;
Type PArray = Array [0..7] of Byte;
Var Tmp: ^PArray; it: Byte; i:Integer;
Begin
Tmp := @i1;
For i := 0 to 3 do Begin
it := Tmp^[i];
Tmp^[i] := Tmp^[7-i];
Tmp^[7-i] := it;
End;
Result := i1;
End;
Der Typ Boolean hat die Zustände True und False. Normalerweise würde 1 Bit ausreichen um diesen Zustand zu Speichern. Da die kleinste Speichereinheit des RAM jedoch 1 Byte ist, wird True in einem Byte als 1 und False al 0 gespeichert.
| Bit
|
7 . . . . . . 0 |
| xxxxxxxM | |
| M=Boolean |
Datenspeicherung True |
||
| Speicheradresse | Little Endian Format Intel CPU |
Big Endian Format Motorola CPU |
$1000 |
$xx |
$xx |
$1001 |
$xx |
$xx |
$1002 |
$01 |
$01 |
$1003 |
$xx |
$xx |
$1004 |
$xx |
$xx |
$1005 |
$xx |
$xx |
$1006 |
$xx |
$xx |
$1007 |
$xx |
$xx |
$1008 |
$xx |
$xx |
$1009 |
$xx |
$xx |
$100A |
$xx |
$xx |
$100B |
$xx |
$xx |
$100C |
$xx |
$xx |
Länge: 8 Bit (1 Byte)
| Typ | Darstellung | Wertebereich | ||||
| Byte | Dezimal | 0 |
255 | |||
| Hexadezimal | $00 |
$FF | ||||
| ShortInt | Dezimal | -128 |
-1 |
0 |
1 |
127 |
| Hexadezimal | $80 |
$FF |
$00 |
$01 |
$7F |
|
Datenspeicherung 18 |
||
| Speicheradresse | Little Endian Format Intel CPU |
Big Endian Format Motorola CPU |
$1000 |
$xx |
$xx |
$1001 |
$xx |
$xx |
$1002 |
$12 |
$12 |
$1003 |
$xx |
$xx |
$1004 |
$xx |
$xx |
$1005 |
$xx |
$xx |
$1006 |
$xx |
$xx |
$1007 |
$xx |
$xx |
$1008 |
$xx |
$xx |
$1009 |
$xx |
$xx |
$100A |
$xx |
$xx |
$100B |
$xx |
$xx |
$100C |
$xx |
$xx |
Länge: 16 Bit (2 Bytes)
| Typ | Darstellung | Wertebereich | ||||
| Word | Dezimal | 0 |
65535 | |||
| Hexadezimal | $0000 |
$FFFF | ||||
| Integer | Dezimal | -32768 |
-1 |
0 |
1 |
32767 |
| Hexadezimal | $8000 |
$FFFF |
$0000 |
$0001 |
$7FFF |
|
Datenspeicherung 4660 |
||
| Speicheradresse | Little Endian Format Intel CPU |
Big Endian Format Motorola CPU |
$1000 |
$xx |
$xx |
$1001 |
$xx |
$xx |
$1002 |
$34 |
$12 |
$1003 |
$12 |
$34 |
$1004 |
$xx |
$xx |
$1005 |
$xx |
$xx |
$1006 |
$xx |
$xx |
$1007 |
$xx |
$xx |
$1008 |
$xx |
$xx |
$1009 |
$xx |
$xx |
$100A |
$xx |
$xx |
$100B |
$xx |
$xx |
$100C |
$xx |
$xx |
Länge: 32 Bit (4 Bytes)
| Typ | Darstellung | Wertebereich | ||||
| Dezimal | 0 |
4294967295 | ||||
| Hexadezimal | $0000 |
$FFFFFFFF | ||||
| LongInt | Dezimal | -2147483648 |
-1 |
0 |
1 |
2147483647 |
| Hexadezimal | $80000000 |
$FFFFFFFF |
$00000000 |
$00000001 |
$7FFFFFFF |
|
Datenspeicherung 305419896 |
||
| Speicheradresse | Little Endian Format Intel CPU |
Big Endian Format Motorola CPU |
$1000 |
$xx |
$xx |
$1001 |
$xx |
$xx |
$1002 |
$78 |
$12 |
$1003 |
$56 |
$34 |
$1004 |
$34 |
$56 |
$1005 |
$12 |
$78 |
$1006 |
$xx |
$xx |
$1007 |
$xx |
$xx |
$1008 |
$xx |
$xx |
$1009 |
$xx |
$xx |
$100A |
$xx |
$xx |
$100B |
$xx |
$xx |
$100C |
$xx |
$xx |
Länge: 64 Bit (8 Bytes)
| Typ | Darstellung | Wertebereich | ||||
| Dezimal | 0 |
18446744073709551615 | ||||
| Hexadezimal | $0000000000000000 |
$FFFFFFFFFFFFFFFF | ||||
| Comp | Dezimal | -9223372036854775808 |
-1 |
0 |
1 |
9223372036854775807 |
| Hexadezimal | $8000000000000000 |
- |
- |
- |
$7FFFFFFFFFFFFFFF |
|
Datenspeicherung |
||
| Speicheradresse | Little Endian Format Intel CPU |
Big Endian Format Motorola CPU |
$1000 |
$xx |
$xx |
$1001 |
$xx |
$xx |
$1002 |
$F0 |
$12 |
$1003 |
$DE |
$34 |
$1004 |
$BC |
$56 |
$1005 |
$9A |
$78 |
$1006 |
$78 |
$9A |
$1007 |
$56 |
$BC |
$1008 |
$34 |
$DE |
$1009 |
$12 |
$F0 |
$100A |
$xx |
$xx |
$100B |
$xx |
$xx |
$100C |
$xx |
$xx |
Single Precision IEEE Real Format
Länge: 32 Bit (4 Bytes)
Genauigkeit: 7 Dezimal Stellen
| Bit
|
31 | 30 . . . . . . 23 | 22 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0 | ||
S |
EEEEEEEE |
MMMMMMM |
MMMMMMMM |
MMMMMMMM |
|
|
|||||
Wertigkeiten |
|
| S = Sign (Vorzeichen) der Mantisse | |
| 0 = positiv 1 = negativ |
|
| E = Exponent zur Basis 2 | |
| -127 .. +128 = 5.877*10-39 ... 3.403*1038 | |
| M = Mantisse zur Basis 2 | |
| Bit
|
22 = 2-1 = 0.5 21 = 2-2 = 0.25 20 = 2-3 = 0.125 19 = 2-4 = 0.0625 18 = 2-5 = 0.03125 17 = 2-6 = 0.015625 16 = 2-7 = 0.0078125 15 = 2-8 = 0.00390625 14 = 2-9 = 0.001953125 13 = 2-10 = 0.0009765625 12 = 2-11 = 0.00048828125 11 = 2-12 = 0.000244140625 10 = 2-13 = 0.0001220703125 9 = 2-14 = 0.00006103515625 8 = 2-15 = 0.000030517578125 7 = 2-16 = 0.0000152587907625 6 = 2-17 = 0.00000762939453125 5 = 2-18 = 0.000003814697265625 4 = 2-19 = 0.0000019073486328125 3 = 2-20 = 0.00000095367431640625 2 = 2-21 = 0.000000476837158203125 1 = 2-22 = 0.0000002384185791015625 0 = 2-23 = 0.00000011920928955078125 |
7 Stellen Genauigkeit
Datenspeicherung Pi = 3.141592654 |
||
| Speicheradresse | Little Endian Format Intel CPU |
Big Endian Format Motorola CPU |
$1000 |
$xx |
$xx |
$1001 |
$xx |
$xx |
$1002 |
$DB |
$40 |
$1003 |
$0F |
$49 |
$1004 |
$49 |
$0F |
$1005 |
$40 |
$DB |
$1006 |
$xx |
$xx |
$1007 |
$xx |
$xx |
$1008 |
$xx |
$xx |
$1009 |
$xx |
$xx |
$100A |
$xx |
$xx |
$100B |
$xx |
$xx |
$100C |
$xx |
$xx |
Double Precision IEEE Real Float
Länge: 64 Bit (8 Bytes)
Genauigkeit: 15 Dezimal Stellen
| Bit
|
63 | 62 . . . . . . . . . 52 | 51 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0 | |||
S |
EEEEEEEEEEE |
MMMMMMM |
... |
MMMMMMMM |
MMMMMMMM |
|
|
||||||
Datenspeicherung Pi = 3.141592654 |
||
| Speicheradresse | Little Endian Format Intel CPU |
Big Endian Format Motorola CPU |
$1000 |
$xx |
$xx |
$1001 |
$xx |
$xx |
$1002 |
$18 |
$40 |
$1003 |
$2D |
$09 |
$1004 |
$44 |
$21 |
$1005 |
$54 |
$FB |
$1006 |
$FB |
$54 |
$1007 |
$21 |
$44 |
$1008 |
$09 |
$2D |
$1009 |
$40 |
$18 |
$100A |
$xx |
$xx |
$100B |
$xx |
$xx |
$100C |
$xx |
$xx |
Extended Precision IEEE Real Float
Länge: 80 Bit (10 Bytes)
Genauigkeit: 19 Dezimal Stellen
| Bit
|
79 | 78. . . . . . . . . 64 | 63. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 0 | |||
S |
EEEEEEEEEEE |
MMMMMMM |
... |
MMMMMMMM |
MMMMMMMM |
|
|
||||||
Datenspeicherung Pi = 3.141592654 |
||
| Speicheradresse | Little Endian Format Intel CPU |
Big Endian Format Motorola CPU |
$1000 |
$xx |
$xx |
$1001 |
$xx |
$xx |
$1002 |
$35 |
$40 |
$1003 |
$C2 |
$00 |
$1004 |
$68 |
$C9 |
$1005 |
$21 |
$0F |
$1006 |
$A2 |
$DA |
$1007 |
$DA |
$A2 |
$1008 |
$0F |
$21 |
$1009 |
$C9 |
$68 |
$100A |
$00 |
$C2 |
$100B |
$40 |
$35 |
$100C |
$xx |
$xx |
Addition |
||||||
Operand |
+Zahl |
-Zahl |
+Null |
-Null |
+ |
- |
+Zahl |
Summe |
Summe |
Summe |
Summe |
+ |
- |
Subtraktion |
||||||
Operand |
+Zahl |
-Zahl |
+Null |
-Null |
+ |
- |
+Zahl |
Differenz |
Differenz |
Differenz |
Differenz |
- |
+ |
Multiplikation |
||||||
Operand |
+Zahl |
-Zahl |
+Null |
-Null |
+ |
- |
+Zahl |
Produkt |
Produkt |
+0.00 |
-0.00 |
+ |
- |
Division |
||||||
Operand |
+Zahl |
-Zahl |
+Null |
-Null |
+ |
- |
+Zahl |
Quotient |
Quotient |
+ |
- |
+0.00 |
-0.00 |
| Copyright Uwe Mnich - E-Mail |