KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Number data types defined in hexadecimal format are automatically converted to decimal
PRODUCT: 4D | VERSION: 17 | PLATFORM: Mac & Win
Published On: January 3, 2019

Whenever a number data type of real or longint is defined, 4D will default the number to the decimal number system. However, it is also possible to define these number data types using the hexadecimal format prefixed with "0x" base. This trick can be useful for 4D commands like Char() since both the decimal and hexadecimal format can be taken as input and will output the correct character. Take the example below as the omega symbol will be returned given both its decimal and hexadecimal value.

C_LONGINT($num1_l;$num2_l)
C_TEXT($text1_t;$text2_t)

$num1_l:=937
$text1_t:=Char($num1_l)

$num2_l:=0x03A9 // this will be automatically converted to its decimal value
$text2_t:=Char($num2_l)




With this behavior, there is no longer any need to manually convert a hexadecimal to decimal. All that is needed is to assign the hexadecimal value to a real or longint number type.