NAME $1 - SYNOPSIS DESCRIPTION IMPLEMENTATION SEE ALSO ARGUMENTS MODIFIED CALLS BUGS convert integer to any radix string integer function gitoc (int, str, size, base) integer int, size, base character str (size) 'Gitoc' will convert an integer to character string representation in any radix from 2 to 16 (inclusive). The integer to be converted may be considered as either signed or unsigned. 'Int' is the integer to be converted; 'str' is a character array into which the string representation will be stored; 'size' is the size of 'str'. The absolute value of 'base' is the conversion radix. If 'base' is negative, then 'int' is treated as an unsigned number; otherwise, 'int' is considered to be a signed. If the specified radix is not in the range 2:16, then a decimal conversion is performed. For a signed conversion, if the integer is less than zero, its absolute value is preceded by a minus sign in the converted string; a positive number is never preceded by a sign. The function return is the number of characters required to represent the integer. 'Gitoc' uses a typical divide-and-remainder algorithm to perform the conversion; that is, a digit is generated by taking the remainder when the integer is divided by the radix. For signed conversions, the absolute value of the number is first taken, the digits generated, and the minus sign inserted if needed. For unsigned conversions, the least significant bit of the number is saved, and then the number is shifted right one bit position to put it into the precision range of a standard integer (and effectively dividing the unsigned number by 2). Then, as each digit value is generated, it is doubled and added to the carry from the previous digit position (with the initial carry being the saved least significant digit) and a new carry value is generated. str It is suspected that this routine will not work properly on one's-complement machines. Also note that it depends on the MAX_INT definition in the Software Tools library to mask off the sign bit of a word. itoc (2), other conversion routines ('cto?*' and '?*toc') (2)