Autor Beitrag
newbie44
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 117

Windows XP, Windows ME
D6 Pers, D7 Enterprise
BeitragVerfasst: Do 22.07.04 18:48 
Hallo,

ich möchte Hexadezimal-Zahlen in integer-zahlen umwandeln, wie mache ich das am besten?

Gruß

sebby :?:


Moderiert von user profile icontommie-lie: Topic aus Dateizugriff verschoben am Fr 23.07.2004 um 13:22
raziel
ontopic starontopic starontopic starontopic starontopic starontopic starofftopic starofftopic star
Beiträge: 2453

Arch Linux
JS (WebStorm), C#, C++/CLI, C++ (VS2013)
BeitragVerfasst: Do 22.07.04 18:52 
ausblenden Delphi-Quelltext
1:
IntToStr(StrToIntDef(strHexZahl, 0));					

Ich nehme an, Du hast die Hex-Zahl als String vorliegen und möchtest sie wieder als String ausgeben. Wichtig: Dem HexZahl-String muss ein $ vorangestellt sein.

raziel

_________________
JSXGraph
newbie44 Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 117

Windows XP, Windows ME
D6 Pers, D7 Enterprise
BeitragVerfasst: Do 22.07.04 19:35 
raziel hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
IntToStr(StrToIntDef(strHexZahl, 0));					

Ich nehme an, Du hast die Hex-Zahl als String vorliegen und möchtest sie wieder als String ausgeben. Wichtig: Dem HexZahl-String muss ein $ vorangestellt sein.

raziel


Ja richtig die Zahlen sind unterschiedlich und heißen zwischen 3B bis zu 1E. Geht das ganze auch irgendwie ohne Doller-Zeichen.

Noch eine Frage kann ich auch irgendwie zeichen wie a oder b als integer schreiben

danke

Sebby :?: :wink:
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Do 22.07.04 21:32 
newbie44 hat folgendes geschrieben:
Ja richtig die Zahlen sind unterschiedlich und heißen zwischen 3B bis zu 1E. Geht das ganze auch irgendwie ohne Doller-Zeichen.
Du kannst das Dollarzeichen nachträglich in deinem Code einfügen:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
strHexZahl := Trim(strHexZahl);
if not (strHexZahl[1] = '$') then
  strDezZahl := IntToStr(StrToIntDef('$' + strHexZahl, 0))
else
  strDezZahl := IntToStr(StrToIntDef(strHexZahl, 0));
ShowMessage('Die Zahl ist: ' + strDezZahl);

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert
newbie44 Threadstarter
ontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic starofftopic star
Beiträge: 117

Windows XP, Windows ME
D6 Pers, D7 Enterprise
BeitragVerfasst: Fr 23.07.04 09:48 
Danke für deine Antwort, doch es geht einfach nicht, es gibt zu viele Script-errors, ich weis nicht wiso, z. B.
:?:
Es gibt keine überladene Version von Trim, die man mit diesem Argumenten aufrufen kann
'if not (strHexZahl[1] = '$') then' Array-Typ erforderlich
incompatible Typen, integer und String.

Was mache ich falsch, muss ich noch Variablen setzten?

Gruß

Sebby :?:

Moderiert von user profile iconPeter Lustig: 45 (!) Fragezeichen-Smilies aus dem Beitrag entfernt ... :roll:
tommie-lie
ontopic starontopic starontopic starontopic starontopic starofftopic starofftopic starofftopic star
Beiträge: 4373

Ubuntu 7.10 "Gutsy Gibbon"

BeitragVerfasst: Fr 23.07.04 11:47 
newbie44 hat folgendes geschrieben:
Es gibt keine überladene Version von Trim, die man mit diesem Argumenten aufrufen kann
'if not (strHexZahl[1] = '$') then' Array-Typ erforderlich
incompatible Typen, integer und String.
Ähhhm... strHexZahl ist aber schon ein String, ja?


Zitat:
Moderiert von user profile iconPeter Lustig: 45 (!) Fragezeichen-Smilies aus dem Beitrag entfernt ... :roll:
In Zusammenhang mit einer anderen Diskussion ist es von seinem Vorteil, daß du die entfernt hast :mrgreen:

_________________
Your computer is designed to become slower and more unreliable over time, so you have to upgrade. But if you'd like some false hope, I can tell you how to defragment your disk. - Dilbert