~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/real.cc

  • Committer: Lee
  • Date: 2008-10-30 22:02:01 UTC
  • mto: (572.1.2 devel)
  • mto: This revision was merged to the branch mainline in revision 573.
  • Revision ID: lbieber@lbieber-desktop-20081030220201-elb6qprbzpn7c5a4
add my name to the AUTHORS file

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
19
19
 */
20
20
 
21
 
#include "config.h"
 
21
 
 
22
using namespace std;
 
23
#include <drizzled/server_includes.h>
22
24
#include <drizzled/field/real.h>
23
25
#include <drizzled/error.h>
24
 
#include <drizzled/table.h>
25
 
 
26
 
#include <math.h>
27
 
 
28
 
#include <limits>
29
 
 
30
 
using namespace std;
31
 
 
32
 
namespace drizzled
33
 
{
34
 
 
35
 
extern const double log_10[309];
36
26
 
37
27
/*
38
28
  Floating-point numbers
44
34
{
45
35
  assert(max_length >= pack_length());
46
36
#ifdef WORDS_BIGENDIAN
47
 
  if (low_byte_first != getTable()->getShare()->db_low_byte_first)
 
37
  if (low_byte_first != table->s->db_low_byte_first)
48
38
  {
49
39
    const unsigned char *dptr= from + pack_length();
50
40
    while (dptr-- > from)
61
51
                   uint32_t param_data, bool low_byte_first)
62
52
{
63
53
#ifdef WORDS_BIGENDIAN
64
 
  if (low_byte_first != getTable()->getShare()->db_low_byte_first)
 
54
  if (low_byte_first != table->s->db_low_byte_first)
65
55
  {
66
56
    const unsigned char *dptr= from + pack_length();
67
57
    while (dptr-- > from)
83
73
{
84
74
  int error= 1;
85
75
  double res= *nr;
86
 
 
87
 
  if (res == numeric_limits<double>::quiet_NaN())
 
76
  
 
77
  if (isnan(res))
88
78
  {
89
79
    res= 0;
90
80
    set_null();
103
93
    max_value-= 1.0 / log_10[dec];
104
94
 
105
95
    /* Check for infinity so we don't get NaN in calculations */
106
 
    if (res != numeric_limits<double>::infinity())
 
96
    if (!(isinf(res)))
107
97
    {
108
98
      double tmp= rint((res - floor(res)) * log_10[dec]) / log_10[dec];
109
99
      res= floor(res) + tmp;
110
100
    }
111
101
  }
112
 
 
 
102
  
113
103
  if (res < -max_value)
114
104
  {
115
105
   res= -max_value;
129
119
}
130
120
 
131
121
 
132
 
int Field_real::store_decimal(const type::Decimal *dm)
 
122
int Field_real::store_decimal(const my_decimal *dm)
133
123
{
134
124
  double dbl;
135
 
  class_decimal2double(E_DEC_FATAL_ERROR, dm, &dbl);
 
125
  my_decimal2double(E_DEC_FATAL_ERROR, dm, &dbl);
136
126
  return store(dbl);
137
127
}
138
128
 
139
 
type::Decimal *Field_real::val_decimal(type::Decimal *decimal_value)
 
129
my_decimal *Field_real::val_decimal(my_decimal *decimal_value)
140
130
{
141
 
  ASSERT_COLUMN_MARKED_FOR_READ;
142
 
 
143
 
  double2_class_decimal(E_DEC_FATAL_ERROR, val_real(), decimal_value);
 
131
  double2my_decimal(E_DEC_FATAL_ERROR, val_real(), decimal_value);
144
132
  return decimal_value;
145
133
}
146
 
 
147
 
} /* namespace drizzled */