/************************************************************
 *
 *     NAME: ltoa
 *  PURPOSE: Convert signed long to decimal string.
 *
 *  SYNOPSIS:
 *
 *      void ltoa( char *s, long bin, unsigned char n );
 *
 *  DESCRIPTION:
 *
 *      The function stores a NUL-terminated string, in "n" +
 *      1 (plus 1 for the NUL string terminator) successive
 *      elements of the array whose first element has the
 *      address "s", by converting "bin" to a sign character
 *      followed by "n" - 1 decimal characters.
 *
 ************************************************************/

void ltoa( char *s, long bin, unsigned char n )
{
    if (bin >= 0)
        *s = '+';
    else
    {
        *s = '-';
        bin = -bin;
    }

    s += n;
    *s = ' ';

    while (--n)
    {
        *--s = (bin % 10) + '0';
        bin /= 10;
    }
}