xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

CtoN()

Converts a string of digits to an integer of the specified base.

Syntax

CtoN( <cDigits> , ;
     [<nBase>]  , ;
     [<lNegative>]) --> nInteger

Arguments

<cDigits>
This is a character string to be converted. It may contain all characters allowed for the specified base. For example, if <nBase> is 16 the characters "0123456789ABCDEF" are allowed. The case of <cDigits> is ignored.
<nBase>
This is a numeric value specifying the base for the conversion. It must be in the range between 2 and 36, and defaults to base 10.
<lNegative>
If .T. (true) is passed, the function takes a minus sign into account. The default is .F. (false), so that only positive values are returned.

Return

The function returns a numeric integer value.

Info

See also:NtoC(), NumToHex()
Category: CT:NumBits , Numbers and Bits
Source:ct\numconv.prg
LIB:xhb.lib
DLL:xhbdll.dll

Example

// The example displays results of number conversions.

   PROCEDURE Main
      ? CtoN( "123" )        // result:        123

      ? CtoN( "123A", 16 )   // result:       4666
      ? NumToHex( 4666 )     // result: 123A

      ? CtoN( "1101", 2 )    // result:         13
      ? NtoC( 11    , 2 )    // result: 1101
   RETURN

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