static char rcsid[] = "$Id: tobase.c,v 1.1 1992/09/06 19:31:32 mike Exp $";

/* $Log: tobase.c,v $
 * Revision 1.1  1992/09/06  19:31:32  mike
 * Initial revision
 *
 */

/* tobase(x,base): convert x to base
	see also todec()
	Craig Durland	Public Domain
*/

#define TRUE 1
#define FALSE 0

char *tobase(x,base) long x; int base;
{
  static char str[40];
  char *ptr = &str[39];
  int minus = FALSE, z;

  *ptr = '\0';
  if (x < 0) { minus = TRUE; x = -x; }
  do
  {
    if ((z = x % base)>9) z += 7;
    *--ptr = z +'0';
    x /= base;
  } while (x>0);
  if (minus) *--ptr = '-';
  return(ptr);
}
