KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Utility Method Converting from Hexadecimal(Base16) to Decimal(Base10)
PRODUCT: 4D | VERSION: 19 | PLATFORM: Mac & Win
Published On: November 21, 2022

There are times when a developer may be working with a string hexadecimal(Base16) and must convert this value to a decimal(Base10).

To perform this task we can pass the desired string to the utility method below

Hex2Dec($1)

#DECLARE($hexa : Text)->$result : Integer
If (Count parameters=1)
   $result:=Formula from string("0x"+$hexa).call()
End if

The above method will return the decimal value as real.

For example:
$dec:=Hex2Dec("100") // returns 256

Note: This method does not handle negatives.