![]() |
HexToInt
Komischerweise enthält Delphi zwar eine Funktionzur Umwandlung von Integer in Hex-Strings, eine Rückwandlung ist nicht vorgesehen. Nachdem ich mir sowas selber geschrieben habe, bin ich zufällig auf eine viel einfachere Lösung gestoßen:
Delphi-Quellcode:
---
function HexToInt(HexNum: string): LongInt;
begin Result:=StrToInt('$' + HexNum); end; Folgender Code ist noch von Clane "eingereicht" worden:
Delphi-Quellcode:
[edit=flomei]Clanes Quelltext hinzugefügt. Mfg, flomei[/edit]
uses
Math; function HexToInt(const HexWert:String):Integer; var i:Integer; s:String; begin Result:=0; s:=UpperCase(HexWert); for i:=1 to Length(s) do if (Ord(s[i]) in [0..47, 58..64, 71..255]) then begin Result:=-1; Break; end; // for i if (Result=0) then for i:=0 to Length(s)-1 do Result:=Result+(HexCharToWert(s[Length(s)-i])*Round(Power(16, i))); end; // HexToInt |
Alle Zeitangaben in WEZ +1. Es ist jetzt 05:04 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz