Browse Source

* added hex2dec64, 64-bit equivalent of hex2dec, mantis #33228

git-svn-id: trunk@38339 -
marco 7 years ago
parent
commit
8ba434b2f4
1 changed files with 14 additions and 1 deletions
  1. 14 1
      packages/rtl-objpas/src/inc/strutils.pp

+ 14 - 1
packages/rtl-objpas/src/inc/strutils.pp

@@ -1,4 +1,4 @@
-{
+{
     Delphi/Kylix compatibility unit: String handling routines.
     Delphi/Kylix compatibility unit: String handling routines.
 
 
     This file is part of the Free Pascal run time library.
     This file is part of the Free Pascal run time library.
@@ -193,6 +193,7 @@ function XorDecode(const Key, Source: string): string;
 function GetCmdLineArg(const Switch: string; SwitchChars: TSysCharSet): string;
 function GetCmdLineArg(const Switch: string; SwitchChars: TSysCharSet): string;
 function Numb2USA(const S: string): string;
 function Numb2USA(const S: string): string;
 function Hex2Dec(const S: string): Longint;
 function Hex2Dec(const S: string): Longint;
+function Hex2Dec64(const S: string): int64;
 function Dec2Numb(N: Longint; Len, Base: Byte): string;
 function Dec2Numb(N: Longint; Len, Base: Byte): string;
 function Numb2Dec(S: string; Base: Byte): Longint;
 function Numb2Dec(S: string; Base: Byte): Longint;
 function IntToBin(Value: Longint; Digits, Spaces: Integer): string;
 function IntToBin(Value: Longint; Digits, Spaces: Integer): string;
@@ -858,6 +859,18 @@ begin
   Result:=StrToInt(HexStr);
   Result:=StrToInt(HexStr);
 end;
 end;
 
 
+function Hex2Dec64(const S: string): int64;
+var
+  HexStr: string;
+begin
+  if Pos('$',S)=0 then
+    HexStr:='$'+ S
+  else
+    HexStr:=S;
+  Result:=StrToInt64(HexStr);
+end;
+
+
 {
 {
   We turn off implicit exceptions, since these routines are tested, and it 
   We turn off implicit exceptions, since these routines are tested, and it 
   saves 20% codesize (and some speed) and don't throw exceptions, except maybe 
   saves 20% codesize (and some speed) and don't throw exceptions, except maybe