~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to strings/longlong2str.c

  • Committer: Jay Pipes
  • Date: 2008-07-17 18:48:58 UTC
  • mto: This revision was merged to the branch mainline in revision 182.
  • Revision ID: jay@mysql.com-20080717184858-2mbouxl8xi41gcge
Removed DBUG from CSV and Blackhole storage engines

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
 
12
12
   You should have received a copy of the GNU General Public License
13
13
   along with this program; if not, write to the Free Software
14
 
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
 
14
   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
15
15
 
16
16
/*
17
17
  Defines: int64_t2str();
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 NULL and nothing will be changed.
 
23
  is dud the result will be NullS 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
#include <my_global.h>
42
41
#include "m_string.h"
43
42
 
44
 
namespace drizzled
45
 
{
46
 
namespace internal
47
 
{
48
 
 
49
43
#if !defined(int64_t2str) && !defined(HAVE_LONGLONG2STR)
50
44
 
51
 
char _dig_vec_upper[] =
52
 
  "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
53
 
 
54
45
/*
55
46
  This assumes that int64_t multiplication is faster than int64_t division.
56
47
*/
87
78
 
88
79
  while (uval > (uint64_t) LONG_MAX)
89
80
  {
90
 
    uint64_t quo= uval/(uint32_t) radix;
91
 
    uint32_t rem= (uint32_t) (uval- quo* (uint32_t) radix);
 
81
    uint64_t quo= uval/(uint) radix;
 
82
    uint rem= (uint) (uval- quo* (uint) radix);
92
83
    *--p = _dig_vec_upper[rem];
93
84
    uval= quo;
94
85
  }
96
87
  while (long_val != 0)
97
88
  {
98
89
    long quo= long_val/radix;
99
 
    *--p = _dig_vec_upper[(unsigned char) (long_val - quo*radix)];
 
90
    *--p = _dig_vec_upper[(uchar) (long_val - quo*radix)];
100
91
    long_val= quo;
101
92
  }
102
93
  while ((*dst++ = *p++) != 0) ;
134
125
 
135
126
  while (uval > (uint64_t) LONG_MAX)
136
127
  {
137
 
    uint64_t quo= uval/(uint32_t) 10;
138
 
    uint32_t rem= (uint32_t) (uval- quo* (uint32_t) 10);
 
128
    uint64_t quo= uval/(uint) 10;
 
129
    uint rem= (uint) (uval- quo* (uint) 10);
139
130
    *--p = _dig_vec_upper[rem];
140
131
    uval= quo;
141
132
  }
143
134
  while (long_val != 0)
144
135
  {
145
136
    long quo= long_val/10;
146
 
    *--p = _dig_vec_upper[(unsigned char) (long_val - quo*10)];
 
137
    *--p = _dig_vec_upper[(uchar) (long_val - quo*10)];
147
138
    long_val= quo;
148
139
  }
149
140
  while ((*dst++ = *p++) != 0) ;
150
141
  return dst-1;
151
142
}
152
143
#endif
153
 
 
154
 
} /* namespace internal */
155
 
} /* namespace drizzled */