DCL
4.0
Loading...
Searching...
No Matches
__XTOA_T.cpp
Go to the documentation of this file.
1
6
7
/***
8
* xtoa.c - convert integers/longs to ASCII string
9
*
10
* Copyright (c) 1989-1997, Microsoft Corporation. All rights reserved.
11
*
12
* Purpose:
13
* The module has code to convert integers/longs to ASCII strings. See
14
*
15
*******************************************************************************/
16
#ifdef __DCL_INTERNAL__
17
18
static
void
XTOA
(
19
unsigned
INT_T
val,
20
CHAR_T
*
buf
,
21
unsigned
radix,
22
int
is_neg
23
)
24
{
25
CHAR_T
*p;
/* pointer to traverse string */
26
CHAR_T
*firstdig;
/* pointer to first digit */
27
CHAR_T
temp;
/* temp char */
28
unsigned
digval;
/* value of digit */
29
30
p =
buf
;
31
32
if
(is_neg) {
33
*p++ =
'-'
;
/* negative, so output '-' and negate */
34
val = (
unsigned
INT_T
)(-(
INT_T
)val);
35
}
36
37
firstdig = p;
/* save pointer to first digit */
38
39
do
{
40
digval = (unsigned) (val % radix);
41
val /= radix;
/* get next digit */
42
43
/* convert to ascii and store */
44
if
(digval > 9)
45
*p++ = (
CHAR_T
) (digval - 10 +
'a'
);
/* a letter */
46
else
47
*p++ = (
CHAR_T
) (digval +
'0'
);
/* a digit */
48
}
while
(val > 0);
49
50
/* We now have the digit of the number in the buffer, but in reverse
51
order. Thus we reverse them now. */
52
53
*p-- =
'\0'
;
/* terminate string; p points to last digit */
54
55
do
{
56
temp = *p;
57
*p = *firstdig;
58
*firstdig = temp;
/* swap *p and *firstdig */
59
--p;
60
++firstdig;
/* advance to next two digits */
61
}
while
(firstdig < p);
/* repeat until halfway */
62
}
63
64
#endif
// #ifdef __DCL_INTERNAL__
CHAR_T
#define CHAR_T
Definition
__STRING.h:20
XTOA
#define XTOA
Definition
__xtoa.cpp:22
INT_T
#define INT_T
Definition
__xtoa.cpp:23
buf
ByteBuffer * buf
Definition
SQLConnection.cpp:176
src
DCLCore
__XTOA_T.cpp
Generated by
1.14.0