Autor Beitrag
zemy
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 207

Win XP Prof.
D7
BeitragVerfasst: Mo 18.07.05 19:11 
Wie kann ich am elegantesten eine SEHR große Zahl (100 Stellen und mehr) in Binär- oder Hexcode umwandeln? Muss ich dafür zwangsläufig ne VLI-Klasse nehmen und immer durch 2 Teilen so wie in der schriftlichen Variante in der Schule oder geht das effizienter?

MfG zemy

_________________
LifeIsToShortToThinkAboutTheShortness
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: Mo 18.07.05 19:36 
Hängt ganz davon ab, wie deine Zahl im Speicher liegt.

Wenn sie im Dezimal-Format vorliegt, hast Du sehr viel Aufwand (besagte Division durch 2\16).

Wenn Du die Zahl im Binär-Format (256 als Basis) hast, dann kannst Du einfach Byteweise die Zahl konvertieren und Zusammenhängen.

_________________
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.
Tilman
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 1405
Erhaltene Danke: 51

Win 7, Android
Turbo Delphi, Eclipse
BeitragVerfasst: Mo 18.07.05 20:12 
Für Hex gibts die Funktionen IntToHex und StrToInt. Soweit ich weiß muss man manchmal ncoh ein Dollarzeichen voranstellen, damit Hex-Zahlen als String erkannt werden.

Darüberhinaus gibts auch noch HexToBin und BinToHex, aber wie die funzen check ich noch nicht so ganz.

// Edit:
bei 100 Stellen nutzt dir das natürlich nix... :(
zemy Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 207

Win XP Prof.
D7
BeitragVerfasst: Do 21.07.05 13:26 
Die Funktionen waren mir auch bekannt. Dummerweise arbeiten die ja mit Integer (bzw. Int64) Geht also doch nur die manuelle Variante :(

_________________
LifeIsToShortToThinkAboutTheShortness