~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mystrings/decimal.cc

  • Committer: Toru Maesaka
  • Date: 2008-12-17 07:16:37 UTC
  • mto: (685.1.40 devel) (713.1.5 devel)
  • mto: This revision was merged to the branch mainline in revision 713.
  • Revision ID: dev@torum.net-20081217071637-7j9040w7lpms77r2
Removed my_time() and added error checking

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
      implementation-defined.
98
98
*/
99
99
 
100
 
#include "config.h"
 
100
#include <drizzled/global.h>
101
101
#include <alloca.h>
102
102
#include <m_string.h>
103
103
#include <m_ctype.h>
104
104
#include <storage/myisam/myisampack.h>
105
105
#include <mystrings/decimal.h>
106
106
 
 
107
#include <drizzled/util/test.h>
107
108
/*
108
109
  Internally decimal numbers are stored base 10^9 (see DIG_BASE below)
109
110
  So one variable of type decimal_digit_t is limited:
126
127
#define DIG_MASK     100000000
127
128
#define DIG_BASE     1000000000
128
129
#define DIG_MAX      (DIG_BASE-1)
129
 
#define DIG_BASE2    ((dec2)DIG_BASE * (dec2)DIG_BASE)
130
130
#define ROUND_UP(X)  (((X)+DIG_PER_DEC1-1)/DIG_PER_DEC1)
131
131
static const dec1 powers10[DIG_PER_DEC1+1]={
132
132
  1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000};
748
748
  beg= ROUND_UP(beg + 1) - 1;
749
749
  end= ROUND_UP(end) - 1;
750
750
  assert(new_point >= 0);
751
 
  
 
751
 
752
752
  /* We don't want negative new_point below */
753
753
  if (new_point != 0)
754
754
    new_point= ROUND_UP(new_point) - 1;
962
962
 
963
963
  rc = decimal2string(from, strbuf, &len, 0, 0, 0);
964
964
  end= strbuf + len;
965
 
  
 
965
 
966
966
  *to= my_strtod(strbuf, &end, &error);
967
 
             
 
967
 
968
968
  return (rc != E_DEC_OK) ? rc : (error ? E_DEC_OVERFLOW : E_DEC_OK);
969
969
}
970
970