Hex - Get the hexadecimal representation of a numeric value

Top  Previous  Next

Syntax

 

<cHexString> := Hex( <nInteger> [,<nSizeInBytes>] )

 

Parameters

 

<nLongInteger>

 

An integer value for which the hexadecimal representation is to be returned. The integer value can be unsigned or signed.

 

<nSizeInBytes>

 

Size in bytes in of <nInteger>. Valid values are 1, 2 and 4. The default value is 1.

 

Return value

 

A string that contains the hexadecimal representation of the value in <nInteger>. If there was a problem converting <nInteger> to its hexadecimal representation, question marks will be returned.

 

Description

 

Hex returns the hexadecimal representation of <nInteger>. <nSizeInBytes> specifies the size of <nInteger>. Specifying 1 allows an unsigned value from 0 to 255 (BYTE) or a signed value from -128 to 127. Specifying 2 as <nSizeInBytes> allows a SHORT or a USHORT to be passed as <nInteger>. A value of 4 for <nSizeInBytes> allows a LONG or a ULONG to be passed for <nInteger>.

 

Classification

 

Core

 

Category

 

Miscellaneous

 

Quick Info

 

Library: cckptcor.lib / cckptcor.dll

 

See also

 

HexString

 

Example

 

 

#INCLUDE "CockpitCoreLibs.ch"

 

FUNCTION Main

 

* This will display "FE"

? Hex(254,1)

? Hex(-2,1)

 

* This will display "FFFE"

? Hex(65534,2)

? Hex(-2,2)

 

* This will display "FFFFFFFF"

? Hex(-1,4)

? Hex(2^32-1,4)

 

RETURN NIL