diff options
Diffstat (limited to 'src/lib/libc/stdlib/l64a.c')
| -rw-r--r-- | src/lib/libc/stdlib/l64a.c | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/lib/libc/stdlib/l64a.c b/src/lib/libc/stdlib/l64a.c new file mode 100644 index 0000000000..3069b31bf6 --- /dev/null +++ b/src/lib/libc/stdlib/l64a.c | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | /* | ||
| 2 | * Written by J.T. Conklin <jtc@netbsd.org>. | ||
| 3 | * Public domain. | ||
| 4 | */ | ||
| 5 | |||
| 6 | #if defined(LIBC_SCCS) && !defined(lint) | ||
| 7 | static char *rcsid = "$NetBSD: l64a.c,v 1.4 1995/05/11 23:04:52 jtc Exp $"; | ||
| 8 | #endif | ||
| 9 | |||
| 10 | #include <stdlib.h> | ||
| 11 | |||
| 12 | char * | ||
| 13 | l64a (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 | } | ||
