Data conversion, Itoa, Ltoa – Argox PA-20 Programming Guide User Manual
Page 108

PT-20 Programming Guide
106
Purpose: Use __itoa to convert an integer value to a null-terminated character string.
Syntax: char * __itoa (int value, char *string, int radix);
Example call: __itoa(32, buffer,
16); /* buffer will contain “20” */
Includes:
#include “SDK.h”
Description: The __itoa function converts the int argument value into a null-terminated
character string using the argument radix as the base of the number
system. The resulting string with a length of up to 17 bytes is saved in the
buffer whose address is given in the argument string. You must allocate
enough room in the buffer to hold all digits of the converted string plus the
terminating null character (\0). For radixes other than 10, the sign bit is not
interpreted; instead, the bit pattern of value is simply expressed in the
requested radix. The argument radix specifies the base (between 2 and 36)
of the number system in which the string representation of value is
expressed. For example, using either 2, 8, 10, or 16 as radix, you can
convert value into its binary, octal, decimal, or hexadecimal representation,
respectively. When radix is 10 and the value is negative, the converted
string will start with a minus sign.
Returns: The __itoa function returns the pointer to the string of degits (i.e., it returns
the argument string).
Purpose: Use __ltoa to convert a long integer value to a null-terminated character
string.
Syntax: char * __ltoa (long value, char *string, int radix);
Example call:
__ltoa(0x10000, string, 10); /* string = “65536” */
Includes:
#include “SDK.h”
Description: The __ltoa function converts the long argument value into acharacter string
using the argument radix as the base of the number system. A long integer
has 32 bits when expressed in radix 2, so the string can occupy a
maximum of 33 bytes with the terminating null character. The resulting
string is returned in the buffer whose address is given in the argument
string. The argument radix specifies the base (between 2 and 36) of the
number system in which the string representation of value is expressed.
For example, using either 2, 8, 10,or 16 as radix, you can convert value into
its binary, octal, decimal, or hexadecimal representation, respectively.