I am looking for a function or formula to convert hexadecimal numbers to decimal and Decimal numbert to Hexadecimal

In Excel I use the "HEX2DEC" and "DEC2HEX" functions but I don't see any similar functions in Crystal.

Sample:

Value in hexadecimal Value in decimal

0x0001 1

0x0002 2

0x0008 8

0x0010 16

0x0020 32

0x0040 64

0x0080 128

0x0100 256

0x0200 512

0x0800 2048

0x1000 4096

0x2000 8192

0x10000 65536

0x20000 131072

0x40000 262144

0x80000 524288

0x100000 1048576

0x200000 2097152

0x400000 4194304

0x800000 8388608

0x1000000 16777216

If I have a decimal number of 66050 the Hexdecimal equivalent is 10202

I am using Crystal Pro 10. My datasource is a CSV file.

Thanks,

Gus Darino

// Hex To Dec

numberVar x := len({?RefNumber});

numberVar base16 := 1;

numberVar value := 0;

numberVar decval := 0;

stringVar s;

while x > 0 do

(

s := mid({?RefNumber},x,1);

if s = "F" then

decval := 15

else if s = "E" then

decval := 14

else if s = "D" then

decval := 13

else if s = "C" then

decval := 12

else if s = "B" then

decval := 11

else if s = "A" then

decval := 10

else

decval := cdbl(s);

value := value + (base16 * decval);

base16 := base16 * 16;

x := x - 1;

);

value;

HTH

frodoman