~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/internal/longlong2str.cc

  • Committer: Brian Aker
  • Date: 2010-05-27 01:25:56 UTC
  • mfrom: (1567.1.4 new-staging)
  • Revision ID: brian@gaz-20100527012556-5zgkirkl7swbigd6
Merge of Brian, Paul. PBXT compile issue, and test framework cleanup. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
  converts the (int64_t) integer "val" to character form and moves it to
21
21
  the destination string "dst" followed by a terminating NUL.  The
22
22
  result is normally a pointer to this NUL character, but if the radix
23
 
  is dud the result will be NullS and nothing will be changed.
 
23
  is dud the result will be NULL and nothing will be changed.
24
24
 
25
25
  If radix is -2..-36, val is taken to be SIGNED.
26
26
  If radix is  2.. 36, val is taken to be UNSIGNED.
37
37
        itoa assumes that 10 -base numbers are allways signed and other arn't.
38
38
*/
39
39
 
 
40
#include "config.h"
 
41
 
40
42
#include "m_string.h"
41
43
 
 
44
namespace drizzled
 
45
{
 
46
namespace internal
 
47
{
 
48
 
42
49
#if !defined(int64_t2str) && !defined(HAVE_LONGLONG2STR)
43
50
 
 
51
char _dig_vec_upper[] =
 
52
  "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
53
 
44
54
/*
45
55
  This assumes that int64_t multiplication is faster than int64_t division.
46
56
*/
77
87
 
78
88
  while (uval > (uint64_t) LONG_MAX)
79
89
  {
80
 
    uint64_t quo= uval/(uint) radix;
81
 
    uint rem= (uint) (uval- quo* (uint) radix);
 
90
    uint64_t quo= uval/(uint32_t) radix;
 
91
    uint32_t rem= (uint32_t) (uval- quo* (uint32_t) radix);
82
92
    *--p = _dig_vec_upper[rem];
83
93
    uval= quo;
84
94
  }
86
96
  while (long_val != 0)
87
97
  {
88
98
    long quo= long_val/radix;
89
 
    *--p = _dig_vec_upper[(uchar) (long_val - quo*radix)];
 
99
    *--p = _dig_vec_upper[(unsigned char) (long_val - quo*radix)];
90
100
    long_val= quo;
91
101
  }
92
102
  while ((*dst++ = *p++) != 0) ;
124
134
 
125
135
  while (uval > (uint64_t) LONG_MAX)
126
136
  {
127
 
    uint64_t quo= uval/(uint) 10;
128
 
    uint rem= (uint) (uval- quo* (uint) 10);
 
137
    uint64_t quo= uval/(uint32_t) 10;
 
138
    uint32_t rem= (uint32_t) (uval- quo* (uint32_t) 10);
129
139
    *--p = _dig_vec_upper[rem];
130
140
    uval= quo;
131
141
  }
133
143
  while (long_val != 0)
134
144
  {
135
145
    long quo= long_val/10;
136
 
    *--p = _dig_vec_upper[(uchar) (long_val - quo*10)];
 
146
    *--p = _dig_vec_upper[(unsigned char) (long_val - quo*10)];
137
147
    long_val= quo;
138
148
  }
139
149
  while ((*dst++ = *p++) != 0) ;
140
150
  return dst-1;
141
151
}
142
152
#endif
 
153
 
 
154
} /* namespace internal */
 
155
} /* namespace drizzled */