ReactOS  0.4.15-dev-344-g6808e40
witow.c
Go to the documentation of this file.
1 /*
2  * COPYRIGHT: See COPYING in the top level directory
3  * PROJECT: ReactOS system libraries
4  * FILE: lib/sdk/crt/string/witow.c
5  * PURPOSE: converts a integer to wchar_t
6  * PROGRAMER:
7  * UPDATE HISTORY:
8  * 1995: Created
9  * 1998: Added ltoa by Ariadne
10  * 2000: derived from ./itoa.c by ea
11  */
12 /* Copyright (C) 1995 DJ Delorie, see COPYING.DJ for details */
13 
14 #include <precomp.h>
15 
16 /*
17  * @implemented
18  */
19 wchar_t* _i64tow(__int64 value, wchar_t* string, int radix)
20 {
21  wchar_t tmp[65];
22  wchar_t* tp = tmp;
23  int i;
24  unsigned v;
25  int sign;
26  wchar_t* sp;
27 
28  if (radix > 36 || radix <= 1) {
30  return 0;
31  }
32 
33  sign = (radix == 10 && value < 0);
34  if (sign)
35  v = -value;
36  else
37  v = (unsigned)value;
38  while (v || tp == tmp) {
39  i = v % radix;
40  v = v / radix;
41  if (i < 10)
42  *tp++ = i+L'0';
43  else
44  *tp++ = i + L'a' - 10;
45  }
46 
47  if (string == 0)
48  string = (wchar_t*)malloc(((tp-tmp)+sign+1)*sizeof(wchar_t));
49  sp = string;
50 
51  if (sign)
52  *sp++ = L'-';
53  while (tp > tmp)
54  *sp++ = *--tp;
55  *sp = 0;
56  return string;
57 }
58 
59 /*
60  * @implemented
61  */
62 wchar_t* _ui64tow(unsigned __int64 value, wchar_t* string, int radix)
63 {
64  wchar_t tmp[65];
65  wchar_t* tp = tmp;
66  long i;
67  unsigned long v = value;
68  wchar_t* sp;
69 
70  if (radix > 36 || radix <= 1) {
72  return 0;
73  }
74 
75  while (v || tp == tmp) {
76  i = v % radix;
77  v = v / radix;
78  if (i < 10)
79  *tp++ = i+L'0';
80  else
81  *tp++ = i + L'a' - 10;
82  }
83 
84  if (string == 0)
85  string = (wchar_t*)malloc(((tp-tmp)+1)*sizeof(wchar_t));
86  sp = string;
87 
88  while (tp > tmp)
89  *sp++ = *--tp;
90  *sp = 0;
91  return string;
92 }
errno_t __cdecl _set_errno(_In_ int _Value)
static size_t double int int int * sign
Definition: printf.c:69
wchar_t * _i64tow(__int64 value, wchar_t *string, int radix)
Definition: witow.c:19
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define EDOM
Definition: errno.h:39
_In_ uint64_t _In_ uint64_t _In_ uint64_t _In_opt_ traverse_ptr * tp
Definition: btrfs.c:2930
static const WCHAR L[]
Definition: oid.c:1250
GLsizei const GLfloat * value
Definition: glext.h:6069
char string[160]
Definition: util.h:11
const GLdouble * v
Definition: gl.h:2040
#define wchar_t
Definition: wchar.h:102
static const WCHAR sp[]
Definition: suminfo.c:288
#define malloc
Definition: debug_ros.c:4
#define __int64
Definition: basetyps.h:16
static unsigned(__cdecl *hash_bstr)(bstr_t s)
wchar_t * _ui64tow(unsigned __int64 value, wchar_t *string, int radix)
Definition: witow.c:62