| xHarbour Reference Documentation > Function Reference |
![]() |
![]() |
![]() |
Converts a numeric value or a pointer to a Hex string.
NumToHex( <nNum>|<pPointer>, [<nLen>]) --> cHexString
The function returns a character string holding the passed value in hexadecimal notation.
NumToHex() converts a numeric value or a pointer to a Hex formatted character string. It converts only integer values. If a number has a decimal fraction, it is ignored. The reverse function is HexToNum().
| See also: | CStr(), HexToNum(), HexToStr(), StrToHex(), StrZero(), Transform() |
| Category: | Numeric functions , Conversion functions , xHarbour extensions |
| Source: | rtl\hbhex2n.c |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example demonstrates return values of NumToHex()
PROCEDURE Main()
? NumToHex( 1 ) // result: 1
? NumToHex( 128 ) // result: 80
? NumToHex( 1 , 4 ) // result: 0001
? NumToHex( 128, 4 ) // result: 0080
? NumToHex( -128 ) // result: FFFFFFFFFFFFFF80
? NumToHex( -1 ) // result: FFFFFFFFFFFFFFFF
? NumToHex( -1 , 4 ) // result: FFFF
? NumToHex( SQrt(2) ) // result: 1
RETURN
http://www.xHarbour.com