hex()

Converts a number to a hexadecimal string or parses a hexadecimal string to a number.

Syntax

hex(value)

Parameters

Parameter Type Description
value Number/String A number to convert to hex or a hex string to parse.

Return Value

Examples

Convert number to hex

hex(255);    // returns "FF"
hex(16);     // returns "10"

Convert hex string to number

hex("FF");   // returns 255
hex("0x1A"); // returns 26

See also

str
strlen
padleft
padright
hex
bin
chr
match