Function Reference

Hex

Returns a string representation of an integer converted to hexadecimal.

Hex ( number, length )

 

Parameters

number The integer to convert.
length Number of characters to be returned (up to 8).
Characters are truncated from the left-hand side if length is too small.

 

Return Value

Success: Returns a string of length characters, zero-padded if necessary.
Special: Returns null string if length is less than 1.
Failure: Returns null string and sets @error to 1 if length is greater than 8.

 

Remarks

The function only works with numbers that fit in a 32 bit signed integer (-2147483648 to 2147483647)

The function will also set @error to 1 if not enough digits were requested - the returned string will return the least significant digits in this case.

 

Related

Dec

 

Example


$result = Hex(1033, 4)  ;returns "0409"