~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/internal/longlong2str.cc

  • Committer: Mark Atwood
  • Date: 2011-12-28 02:50:31 UTC
  • Revision ID: me@mark.atwood.name-20111228025031-eh4h1zwv4ig88g0i
fix tests/r/basic.result

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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
 
14
   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA */
15
15
 
16
16
/*
17
17
  Defines: int64_t2str();
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
namespace internal {
 
46
 
42
47
#if !defined(int64_t2str) && !defined(HAVE_LONGLONG2STR)
43
48
 
 
49
char _dig_vec_upper[] =
 
50
  "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
 
51
 
44
52
/*
45
53
  This assumes that int64_t multiplication is faster than int64_t division.
46
54
*/
48
56
char *int64_t2str(int64_t val,char *dst,int radix)
49
57
{
50
58
  char buffer[65];
51
 
  register char *p;
52
59
  long long_val;
53
60
  uint64_t uval= (uint64_t) val;
54
61
 
72
79
    *dst='\0';
73
80
    return dst;
74
81
  }
75
 
  p = &buffer[sizeof(buffer)-1];
 
82
  char* p = &buffer[sizeof(buffer)-1];
76
83
  *p = '\0';
77
84
 
78
85
  while (uval > (uint64_t) LONG_MAX)
79
86
  {
80
 
    uint64_t quo= uval/(uint) radix;
81
 
    uint32_t rem= (uint) (uval- quo* (uint) radix);
 
87
    uint64_t quo= uval/(uint32_t) radix;
 
88
    uint32_t rem= (uint32_t) (uval- quo* (uint32_t) radix);
82
89
    *--p = _dig_vec_upper[rem];
83
90
    uval= quo;
84
91
  }
99
106
char *int64_t10_to_str(int64_t val,char *dst,int radix)
100
107
{
101
108
  char buffer[65];
102
 
  register char *p;
103
109
  long long_val;
104
110
  uint64_t uval= (uint64_t) val;
105
111
 
119
125
    *dst='\0';
120
126
    return dst;
121
127
  }
122
 
  p = &buffer[sizeof(buffer)-1];
 
128
  char* p = &buffer[sizeof(buffer)-1];
123
129
  *p = '\0';
124
130
 
125
131
  while (uval > (uint64_t) LONG_MAX)
126
132
  {
127
 
    uint64_t quo= uval/(uint) 10;
128
 
    uint32_t rem= (uint) (uval- quo* (uint) 10);
 
133
    uint64_t quo= uval/(uint32_t) 10;
 
134
    uint32_t rem= (uint32_t) (uval- quo* (uint32_t) 10);
129
135
    *--p = _dig_vec_upper[rem];
130
136
    uval= quo;
131
137
  }
140
146
  return dst-1;
141
147
}
142
148
#endif
 
149
 
 
150
} /* namespace internal */
 
151
} /* namespace drizzled */