~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mystrings/decimal.c

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

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