l64a.c revision 1.4
1/* 2 * Written by J.T. Conklin <jtc@netbsd.org>. 3 * Public domain. 4 */ 5 6#if defined(LIBC_SCCS) && !defined(lint) 7static char *rcsid = "$NetBSD: l64a.c,v 1.4 1995/05/11 23:03:44 jtc Exp $"; 8#endif 9 10#include <stdlib.h> 11 12char * 13l64a (value) 14 long value; 15{ 16 static char buf[8]; 17 char *s = buf; 18 int digit; 19 int i; 20 21 if (!value) 22 return NULL; 23 24 for (i = 0; value != 0 && i < 6; i++) { 25 digit = value & 0x3f; 26 27 if (digit < 2) 28 *s = digit + '.'; 29 else if (digit < 12) 30 *s = digit + '0' - 2; 31 else if (digit < 38) 32 *s = digit + 'A' - 12; 33 else 34 *s = digit + 'a' - 38; 35 36 value >>= 6; 37 s++; 38 } 39 40 *s = '\0'; 41 42 return buf; 43} 44