xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

HexToNum()

Converts a Hex string to a numeric value.

Syntax

HexToNum( <cHexString> ) --> nNumber

Arguments

<cHexString>
This is a character string holding an integer number in hexadecimal format.

Return

The function returns the decoded Hex string as a numeric value.

Description

HexToNum() converts a Hex formatted character string to a numeric value. It converts only characters in the range from "0-9" and "a-f" or "A-F". If <cHexString> contains any other character, the conversion is stopped. The reverse function is NumToHex().

Info

See also:CStr(), HexToStr(), NumToHex(), 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 HexToNum()

   PROCEDURE Main
      ? HexToNum( "1" )                 // result:         1

      ? HexToNum( "FF" )                // result:       255
      ? HexToNum( "FFFF" )              // result:     65535

      ? HexToNum( "FFFFFFFFFFFFFFFF" )  // result:        -1
      ? HexToNum( "ffffffffffffff80" )  // result:      -128
   RETURN

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