Autor Beitrag
Mortal-Shadow
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 110



BeitragVerfasst: Di 18.11.08 22:51 
Mir ist folgendes Aufgefallen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
setlength(mystring,2);
PWord(@mystring[1])^ := $4711;
For count1 := 1 to length(mystring) do
     memo1.lines.append(IntToHex(Ord(mystring[count1]),2)+ #32); // hex-Wert + Leerzeichen

ergibt als Ausgabe:
11 47.

Also gerade verdreht.
Heist das, dass der Computer Daten "verkehrt" herum abspeichert?
Also wir schreiben eine 3 im Binärformat ja: ...00011;
Sind sie im Computer nun als: 11000... abgespeichert?
Wenn ja, warum diese Diskrepanz?
Wenn nein, warum der Zahlenverdreher?

Gruß, MS.
BenBE
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 8721
Erhaltene Danke: 191

Win95, Win98SE, Win2K, WinXP
D1S, D3S, D4S, D5E, D6E, D7E, D9PE, D10E, D12P, DXEP, L0.9\FPC2.0
BeitragVerfasst: Di 18.11.08 22:58 
Siehe Little Endian und Big Endian in der Wiki ;-)

_________________
Anyone who is capable of being elected president should on no account be allowed to do the job.
Ich code EdgeMonkey - In dubio pro Setting.
Xentar
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 2077
Erhaltene Danke: 2

Win XP
Delphi 5 Ent., Delphi 2007 Prof
BeitragVerfasst: Di 18.11.08 23:00 
user profile iconMortal-Shadow hat folgendes geschrieben Zum zitierten Posting springen:
Heist das, dass der Computer Daten "verkehrt" herum abspeichert?

Jein.

user profile iconMortal-Shadow hat folgendes geschrieben Zum zitierten Posting springen:
Also wir schreiben eine 3 im Binärformat ja: ...00011;
Sind sie im Computer nun als: 11000... abgespeichert?

Nein.

Die Reihenfolge wird Byte-weise vertauscht. Ein Byte ist immer "richtigrum".
Siehe
de.wikipedia.org/wiki/Little_endian

_________________
PROGRAMMER: A device for converting coffee into software.
Mortal-Shadow Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 110



BeitragVerfasst: Di 18.11.08 23:11 
Ah, ok - vielen Dank für den Link.