xHarbour Reference Documentation > Function Reference xHarbour Developers Network  

NtoC()

Converts an integer to a string of digits for a specified number base.

Syntax

NtoC( <nInteger>|<cHex>, ;
     [<nBase>]         , ;
     [<nLength>        , ;
     [<cPad>]            ) --> cString

Arguments

<nInteger>
A numeric 32-bit integer value can be specified as first parameter.
<cHex>
Alternatively, the integer can be passed as a hex-encoded character string (see NumToHex()).
<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.
<nLength>
Optionally, the length of the returned string can be specified as a numeric value.
<cPad>
If <mLength> is larger than the required string, the return string is padded on the left with <cPad> up to the desired length. The default value for <cPad> ia a blank space (Chr(32)).

Return

The function returns a character string. It holds the digit representation of <nIneger> for the specified number base. If there is an error, or <nLength> is specified too small, a character string filled with asterisks is returned.

Info

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

Example

// The example displays results of NtoC() for different
// number bases.

   PROCEDURE Main
      ? NtoC( 13 )        // result: 13
      ? NtoC( 13, 2  )    // result: 1101
      ? NtoC( 13, 16 )    // result: D
   RETURN

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