~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mystrings/decimal.cc

  • Committer: Monty Taylor
  • Date: 2009-03-08 23:45:12 UTC
  • mto: (923.2.1 mordred)
  • mto: This revision was merged to the branch mainline in revision 921.
  • Revision ID: mordred@inaugust.com-20090308234512-tqkygxtu1iaig23s
Removed C99 isnan() usage, which allows us to remove the util/math.{cc,h} workarounds. Yay for standards!

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