Delphi/CB
•  Greatis •  Security •  AppDatabase •  Utilities •  Visual Basic • .NET •  just4fun
Delphi / C++ Builder
Components, utilities and tips for Delphi and C++ Builder developers
Hot Offer
Save your money!
Featured
Ultimate Pack  hot!
Image Editor  new!
Runtime Fusion
Form Designer
Object Inspector
Print Suite Pro
Commented Image
Delphi Toys
WinDowse
Delphi Bonus
TMS Scripter Studio
Form Designer VB
Form Designer .NET

...get more...
for Delphi.NET, C#, VB.NET
for Delphi VCL, BCB 3-6

News Tips .NET Software VCL Software Partners  

Convert hexadecimal to binary
Hexadecimal format of a number is a reduced binary format of this number. Use HexToBin function to convert hexadecimal to binary format.

function HexToBin(HexStr: string): string;
const
  BinArray: array[0..15, 0..1] of string =
    (('0000', '0'), ('0001', '1'), ('0010', '2'), ('0011', '3'),
     ('0100', '4'), ('0101', '5'), ('0110', '6'), ('0111', '7'),
     ('1000', '8'), ('1001', '9'), ('1010', 'A'), ('1011', 'B'),
     ('1100', 'C'), ('1101', 'D'), ('1110', 'E'), ('1111', 'F'));
  HexAlpha: set of char = ['0'..'9', 'A'..'F'];
var
  i, j: Integer;
begin
  Result:='';
  HexStr:=AnsiUpperCase(HexStr);
  for i:=1 to Length(HexStr) do
    if HexStr[i] in HexAlpha then
    begin
      for j:=1 to 16 do
        if HexStr[i]=BinArray[j-1, 1] then
          Result:=Result+BinArray[j-1, 0];
    end
    else
    begin
      Result:='';
      ShowMessage('This is not hexadecimal number');
      Break;
    end;
  if Result<>'' then
   while (Result[1]='0')and(Length(Result)>1) do
     Delete(result, 1, 1);
end;

Related topics
Convert binary to hexadecimal
Convert binary to octal
Convert octal to binary
Convert octal to decimal
Convert decimals to binary
Convert decimals to hexadecimals
Convert hexadecimals to decimals
Convert binary to decimals

For more
Delphi Help

Download source


Our Partner
DevArchive.com
Recommended
just4fun
Useful Resources
Win32.hlp Online
Unix Manual Pages
MegaDetailed.NET
in3steps.com
Newsletters
Subscribe to our news!    Subscribe to our news!


Greatis Software Greatis | Security | AppDatabase | Utilities | Delphi/CB | Visual Basic | .NET | just4fun

Contacts | Add to Favorites | Recommend to a Friend | Privacy Policy | Copyright © 1998-2008 Greatis Software