/ lang / hex
Hex$
Syntax

    String = Hex$ ( Number AS Long [ , Digits AS Integer ] )

Gets the hexadecimal representation of a number.

If Digits is specified, the representation is padded with unnecessary zeros so that Digits digits are returned.

### Examples

    PRINT Hex$(1972)
    <hr>7B4

    PRINT Hex$(1972, 8)
    <hr>000007B4

The sign of a Short or Integer will be extended, because the Number will be extended to Long . If the hexadecimal representation should be limited to 16 bits the AND operator must be used.

    DIM bX AS Byte ' 8 bits unsigned
    DIM sX AS Short ' 16 Bits signed

    bX = 200
    sX = -456
    PRINT Hex$(bX), Hex$(sX), Hex$(CLong(sX) AND &hffff&)
    <hr>C8	FFFFFFFFFFFFFE38	FE38

### See also

Formatting functions