WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

Numbers

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

Hex to Decimal Conversion

 Keywords:  Hex Decimal conversion xHex

This UDF is nice for Hex to Decimal conversions when one does not wish the additional baggage of the WILX extender.
#DefineFunction Hex2Dec(hex)
   str="0123456789ABCDEF"
   hex=StrTrim(StrUpper(hex))
   hexlen=StrLen(hex)
   dec=0
   for x=1 to hexlen
       dec=(dec*16) + StrIndex(str,strsub(hex,x,1),0,@fwdscan) -1
   next
   return(dec)
#EndFunction


;Example Usage
a="07D0"
b=Hex2Dec(a)
Message(a,b)

Here is a sample that uses the Huge Math Extender for very large number conversions
#DefineFunction Hex2Dec(hex)
   AddExtender("wwhug34i.dll") ; Huge Math Extender
   str="0123456789ABCDEF"
   hex=StrTrim(StrUpper(hex))
   hexlen=StrLen(hex)
   dec=0
   for x=1 to hexlen
	     by16 = huge_Multiply(dec,16)
	     ptr = StrIndex(str,strsub(hex,x,1),0,@fwdscan)-1
	     dec = huge_Add( by16, ptr)
   next
   return(dec)
#EndFunction

;Example Usage
a="FFFFFD81"
b=Hex2Dec(a)
Message(a,b)
Exit

Article ID:   W14751
Filename:   Hex to Decimal Conversion.txt
File Created: 2009:12:10:14:11:20
Last Updated: 2009:12:10:14:11:20