DECTOHEX

This command converts a decimal (base 10) value to its hexadecimal equivalent.

Syntax

DECTOHEX number

Number can be any value from -2,147,483,648 through 2,147,483,647. If you specify a number with decimal places, it will be rounded to the nearest integer.

Return value

This command returns a string.

Notes

This command returns the hexadecimal value of the specified integer, formatted as a string. The return value will not include leading zeroes or any prefix such as "0x".

If the number you specify is negative, the returned hexadecimal value is represented as a two's-complement signed 32-bit value. (More information at https://www.cs.cornell.edu/~tomf/notes/cps104/twoscomp.html and https://www.mathsisfun.com/binary-decimal-hexadecimal-flash.html.)

If the number you specify is invalid, this command returns an empty string.

See also: VAL, HEXTODEC

Examples

DECTOHEX 95

This formula returns the string "5F".

DECTOHEX 94.6

This formula rounds the number 94.6 to 95 and returns the string "5F".

DECTOHEX -95

This formula returns the string "FFFFFFA1".

DECTOHEX "246"

The value "246" is a string instead of a number, so this formula returns the empty string "".

DECTOHEX (VAL "246")

This formula uses the VAL command to return the numeric value of a string, so this formula first converts the string "246" to the number 246 and then returns the string "F6".

DECTOHEX 2147483647

This formula returns the string "7FFFFFFF".

DECTOHEX -2147483648

This formula returns the string "80000000".