xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

NumToHex()

Converts a numeric value or a pointer to a Hex string.

Syntax

NumToHex( <nNum>|<pPointer>, [<nLen>]) --> cHexString

Arguments

<nNum>|<pPointer>
The first parameter is eiher a numeric value or a pointer to convert to hexadecimal notation.
<nLen>
An optional numeric value specifying the length of the return string.

Return

The function returns a character string holding the passed value in hexadecimal notation.

Description

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().

Info

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

Example

// 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

Copyright © 2006-2007 xHarbour.com Inc. All rights reserved.
http://www.xHarbour.com
Created by docmaker.exe