Solved

# a conversion from decimal to hex and vise versa

Posted on 2000-05-03

I need 3 VBScript functions something like

- convertToHex(decnumber)

- convertToDecimal(hexnumber)

- shift right function

Now that may sound easy but I cannot arrive to make the conversion function to work for the values

4294967295 for convertToHex

FFFFFFFF for convertToDecimal

I get an overflow message error.

And the last function, the shift right, is also wrong by 1! Try it with shr(4294967295,4) to understand what I mean and check the result with MS calculator.

My functions:

'Return a long number in hexadecimal (i.e. hex(69) )

function hexa(n)

tmpResult = hex(n)

for i=len(tmpResult) to 7 step 1

tmpResult = "0" + tmpResult

next

hexa = LCase(tmpResult)

end function

'Return a hexadecimal number in decimal (i.e. deci(&HFF) )

function deci(n)

deci = clng(n)

end function

'function shift right by b

function shr(a,b)

for i=1 to b step 1

a = int(a/2)

next

shr = a

end function

Maybe you guys can end up with a solution.