Files
Sepp J Morris 31738079c4 Upload
Digital Research
2020-11-06 18:50:37 +01:00

39 lines
1.1 KiB
C
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*----------------------------------------------------------------------*\
| NAME : itoa |
| CREATED : 16-August-83 LAST MODIFIED: 16-August-83 |
| FUNCTION: Itoa converts a WORD (integer) into an ASCII string |
| that represents that number. |
| INPUT : number -- number to conver. |
| str -- ptr to string that will hold the |
| converted number. |
| OUTPUT : Fills in the string pointed to by str with the ASCII |
| representation of number. |
| No return value. |
\*----------------------------------------------------------------------*/
#include <portab.h>
#include "utildef.h"
EXTERN VOID reverse();
VOID itoa( number,str )
WORD number; /* number to convert to string */
BYTE str[]; /* converted number */
{
WORD sindex; /* string index */
WORD sign; /* number sign */
if( (sign = number) < 0 )
number = -number;
sindex = 0;
do
str[sindex++] = (number % 10) + '0';
while( (number /= 10) > 0 );
if( sign < 0 )
str[sindex++] = '-';
str[sindex] = NULL;
reverse( str );
}