home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
t
/
tcsel003.zip
/
HEXCONV.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1992-10-16
|
762b
|
31 lines
var
n : word;
long : longint;
function Byte2Hex(numb : byte): string; { Converts byte to hex string }
const
HexChars : array[0..15] of char = '0123456789ABCDEF';
begin
Byte2Hex[0] := #2;
Byte2Hex[1] := HexChars[numb shr 4];
Byte2Hex[2] := HexChars[numb and 15];
end; { Byte2Hex }
function Numb2Hex(numb: word): string; { Converts word to hex string.}
begin
Numb2Hex := Byte2Hex(hi(numb))+Byte2Hex(lo(numb));
end; { Numb2Hex }
function Long2Hex(L: longint): string; { Converts longint to hex string }
begin
Long2Hex := Numb2Hex(L shr 16) + Numb2Hex(L);
end; { Long2Hex }
begin
long := 65536;
n := 256;
writeln(Long2Hex(long));
writeln(Numb2Hex(n));
end.