Converts the numbers in a digit string into a different number base


       NTOC( <xNumber>[, <nBase>][,<nLength>][,<cPadChar>] ) -> <cNumber>


<xNumber> Corresponds to a decimal number or hexadecimal character string to convert. <nBase> Designates the number system base, from 2 to 36 (inclusive), to use in the result. The default is the decimal system, base 10. <nLength> Designates the length of the string that results. The maximum length is 255. The default is the length required for the conversion. <cPadChar> Designates a pad character to pad the string result on the left. The default value is a space.


NTOC() returns a character string that contains the conversion result of <nLONG|cHexLONG> into the <nBase> number system.


NTOC() converts a decimal number or hexadecimal string into a number string. The result is a number in base <nBase> or, if <nBase> is not specified, in base 10. Use <nLength> to determine the length of the result string. However, if <nLength> is longer than the length necessary for the result, the result string is padded on the left with spaces or with a character selected with <cPad>.


. If incompatible parameter combinations are specified, NTOC() returns one or more asterisks (*) as a result.


       .  Convert to base 10:
              ? NTOC (60000)                //"60000"
              ? NTOC (60000, 10, 7)         //"    60000"
           .  Convert to base 2:
              ? NTOC(60000, 2)              // "1110101001100000"
              ? NTOC("FFFF", 2)             // "1111111111111111"
              ? NTOC("30", 2, 8, "0")       // "00110000"
           .  Convert to base 16:
              ? NTOC(43981, 16)             // "ABCD"
           .  Convert to base 36:
              ? NTOC(43981, 36, 4)          // "XXP"
           .  Invalid parameters (overflow):
              ? NTOC("GGGG", 2)             // "*"
              ? NTOC(60000, 10, 3)          // "***"
              ? NTOC(60000, 1, 4)           // "****"




Source is numconv.prg, library is libct.




2 responses to “NTOC()

  1. Pingback: Harbour Conversion Functions | Viva Clipper !

  2. Pingback: Harbour All Functions – N | Viva Clipper !

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s