home *** CD-ROM | disk | FTP | other *** search
- unit hexfun;
-
- interface
-
- uses windows,sysutils,math;
-
- function hex2int (hexdigit : string):dword;
-
- implementation
-
- function hex2int (hexdigit : string):dword;
- var i,m: integer;
- zw : extended;
- t,n: longint;
- hextmp : string;
- intdigit : dword;
- begin
- for i:=length(hexdigit) downto 1 do hextmp:=hextmp+hexdigit[i];
- intdigit:=0;
- for i:=length(hextmp)downto 1 do
- begin
- case upcase(hextmp[i]) of
- 'A' : m:=10;
- 'B' : m:=11;
- 'C' : m:=12;
- 'D' : m:=13;
- 'E' : m:=14;
- 'F' : m:=15;
- else
- m:=strtoint(hextmp[i]);
- end;
- zw:=intpower(16,i-1);
- n:=trunc(zw);
- t:=m*n;
- intdigit:=intdigit+t;
- end;
- result:=intdigit;
- end;
-
- begin;
- end.
-