We’ve covered the major pseudocode formatting options previously but there is one more option which can influence the output. It is the radix used for printing numbers in the pseudocode.
In a positional numeral system, the radix or base is the number of unique digits, including the digit zero, used to represent numbers. For example, for the decimal/denary system (the most common system in use today) the radix (base number) is ten, because it uses the ten digits from 0 through 9.
The default radix setting is 0, which means “automatic”.
With this setting, the decompiler uses hexadecimal radix for values detected as unsigned, and decimal otherwise. For example, in the below screenshot, arguments to
CContextMenuManager::AddMenu() are shown in hex because the function prototype specifies the last argument type as “unsigned int”, while those for
LoadStringA() are in decimal because the decompiler used a guessed prototype with the type
_DWORD which behaves like a signed type.
In some cases, the decompiler may use hex even for signed numbers if it makes the number look “nice”. Currently (as of IDA 7.7), the following rules are used:
- values matching 2n and 2n-1 (typical bitmasks) are printed as hexadecimal.
- 64-bit values which have not all-zero or all-one high 32 bits are printed as hexadecimal unless they end with more than 3 zeroes in decimal representation.
- -1 is printed as decimal.
Changing the radix manually
You can always change the representation for a specific number in pseudocode from the context menu or via a hotkey.
To toggle between decimal and hex, use the H hotkey. Octal is available only via the context menu by default, but it’s possible to add a custom hotkey for the action name
Setting preferred radix
By changing Default radix in the decompiler options, you can have decompiler always use decimal (10) or hexadecimal(16) for all numbers without an explicitly set radix. Note that in this case the “nice” number detection will be disabled.
To change the default for all new databases, set the value DEFAULT_RADIX in
hexrays.cfg as described in the previous post.