3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/crtdll/stdlib/itow.c
6 * PURPOSE: converts a integer to wchar_t
10 * 1998: Added ltoa Boudewijn Dekker
11 * 2000: derived from ./itoa.c by ea
13 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
14 #include <crtdll/errno.h>
15 #include <crtdll/stdlib.h>
16 #include <crtdll/internal/file.h>
19 _itow (int value, wchar_t *string, int radix)
28 if (radix > 36 || radix <= 1)
34 sign = ((radix == 10) && (value < 0));
43 while (v || tp == tmp)
49 *tp++ = i+ (wchar_t) '0';
53 *tp++ = i + (wchar_t) 'a' - 10;
59 string = (wchar_t *) malloc((tp-tmp) + (sign + 1) * sizeof(wchar_t));
65 *sp++ = (wchar_t) '-';
77 _ltow (long value, wchar_t *string, int radix)
86 if (radix > 36 || radix <= 1)
92 sign = ((radix == 10) && (value < 0));
99 v = (unsigned long) value;
101 while (v || tp == tmp)
107 *tp++ = i + (wchar_t) '0';
111 *tp++ = i + (wchar_t) 'a' - 10;
117 string = (wchar_t *) malloc((tp - tmp) + (sign + 1) * sizeof(wchar_t));
123 *sp++ = (wchar_t) '-';
134 _ultow (unsigned long value, wchar_t *string, int radix)
139 unsigned long int v = value;
142 if (radix > 36 || radix <= 1)
147 while (v || tp == tmp)
153 *tp++ = i + (wchar_t) '0';
157 *tp++ = i + (wchar_t) 'a' - 10;
163 string = (wchar_t *) malloc((tp - tmp) + sizeof(wchar_t));