~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/field/real.cc

  • Committer: Brian Aker
  • Date: 2010-12-08 22:35:56 UTC
  • mfrom: (1819.9.158 update-innobase)
  • Revision ID: brian@tangent.org-20101208223556-37mi4omqg7lkjzf3
Merge in Stewart's changes, 1.3 changes.

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 <drizzled/server_includes.h>
 
21
#include "config.h"
22
22
#include <drizzled/field/real.h>
23
23
#include <drizzled/error.h>
24
24
#include <drizzled/table.h>
25
 
#include CMATH_H
26
 
#include <drizzled/util/math.h>
27
 
 
28
 
#if defined(CMATH_NAMESPACE)
29
 
using namespace CMATH_NAMESPACE;
30
 
#endif
 
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];
31
36
 
32
37
/*
33
38
  Floating-point numbers
39
44
{
40
45
  assert(max_length >= pack_length());
41
46
#ifdef WORDS_BIGENDIAN
42
 
  if (low_byte_first != table->s->db_low_byte_first)
 
47
  if (low_byte_first != getTable()->getShare()->db_low_byte_first)
43
48
  {
44
49
    const unsigned char *dptr= from + pack_length();
45
50
    while (dptr-- > from)
56
61
                   uint32_t param_data, bool low_byte_first)
57
62
{
58
63
#ifdef WORDS_BIGENDIAN
59
 
  if (low_byte_first != table->s->db_low_byte_first)
 
64
  if (low_byte_first != getTable()->getShare()->db_low_byte_first)
60
65
  {
61
66
    const unsigned char *dptr= from + pack_length();
62
67
    while (dptr-- > from)
78
83
{
79
84
  int error= 1;
80
85
  double res= *nr;
81
 
  
82
 
  if (isnan(res))
 
86
 
 
87
  if (res == numeric_limits<double>::quiet_NaN())
83
88
  {
84
89
    res= 0;
85
90
    set_null();
98
103
    max_value-= 1.0 / log_10[dec];
99
104
 
100
105
    /* Check for infinity so we don't get NaN in calculations */
101
 
    if (!(isinf(res)))
 
106
    if (res != numeric_limits<double>::infinity())
102
107
    {
103
108
      double tmp= rint((res - floor(res)) * log_10[dec]) / log_10[dec];
104
109
      res= floor(res) + tmp;
105
110
    }
106
111
  }
107
 
  
 
112
 
108
113
  if (res < -max_value)
109
114
  {
110
115
   res= -max_value;
133
138
 
134
139
my_decimal *Field_real::val_decimal(my_decimal *decimal_value)
135
140
{
 
141
  ASSERT_COLUMN_MARKED_FOR_READ;
 
142
 
136
143
  double2my_decimal(E_DEC_FATAL_ERROR, val_real(), decimal_value);
137
144
  return decimal_value;
138
145
}
 
146
 
 
147
} /* namespace drizzled */