l64a.c revision 1.6
11.1Sjtc/*
21.4Sjtc * Written by J.T. Conklin <jtc@netbsd.org>.
31.4Sjtc * Public domain.
41.1Sjtc */
51.1Sjtc
61.5Schristos#include <sys/cdefs.h>
71.1Sjtc#if defined(LIBC_SCCS) && !defined(lint)
81.6Sjtc__RCSID("$NetBSD: l64a.c,v 1.6 1997/07/21 14:08:53 jtc Exp $");
91.1Sjtc#endif
101.1Sjtc
111.6Sjtc#include "namespace.h"
121.1Sjtc#include <stdlib.h>
131.6Sjtc
141.6Sjtc#ifdef __weak_alias
151.6Sjtc__weak_alias(l64a,_l64a);
161.6Sjtc#endif
171.1Sjtc
181.1Sjtcchar *
191.1Sjtcl64a (value)
201.1Sjtc	long value;
211.1Sjtc{
221.1Sjtc	static char buf[8];
231.1Sjtc	char *s = buf;
241.1Sjtc	int digit;
251.1Sjtc	int i;
261.1Sjtc
271.1Sjtc	if (!value)
281.1Sjtc		return NULL;
291.1Sjtc
301.1Sjtc	for (i = 0; value != 0 && i < 6; i++) {
311.1Sjtc		digit = value & 0x3f;
321.1Sjtc
331.1Sjtc		if (digit < 2)
341.1Sjtc			*s = digit + '.';
351.1Sjtc		else if (digit < 12)
361.1Sjtc			*s = digit + '0' - 2;
371.1Sjtc		else if (digit < 38)
381.1Sjtc			*s = digit + 'A' - 12;
391.1Sjtc		else
401.1Sjtc			*s = digit + 'a' - 38;
411.1Sjtc
421.1Sjtc		value >>= 6;
431.1Sjtc		s++;
441.1Sjtc	}
451.1Sjtc
461.1Sjtc	*s = '\0';
471.1Sjtc
481.1Sjtc	return buf;
491.1Sjtc}
50