~drizzle-trunk/drizzle/development

492.3.1 by Lee
break out item_real_func into functions directory
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 *
4
 *  Copyright (C) 2008 Sun Microsystems
5
 *
6
 *  This program is free software; you can redistribute it and/or modify
7
 *  it under the terms of the GNU General Public License as published by
8
 *  the Free Software Foundation; version 2 of the License.
9
 *
10
 *  This program is distributed in the hope that it will be useful,
11
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 *  GNU General Public License for more details.
14
 *
15
 *  You should have received a copy of the GNU General Public License
16
 *  along with this program; if not, write to the Free Software
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 */
19
1241.9.36 by Monty Taylor
ZOMG. I deleted drizzled/server_includes.h.
20
#include "config.h"
1241.9.1 by Monty Taylor
Removed global.h. Fixed all the headers.
21
#include <math.h>
642.1.30 by Lee
move math functions to drizzled/function/math directory
22
#include <drizzled/function/math/real.h>
492.3.1 by Lee
break out item_real_func into functions directory
23
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
24
namespace drizzled
25
{
26
520.4.44 by mordred
A whole bunch of solaris/sun studio compile fixes.
27
492.3.1 by Lee
break out item_real_func into functions directory
28
String *Item_real_func::val_str(String *str)
29
{
30
  assert(fixed == 1);
31
  double nr= val_real();
32
  if (null_value)
971.6.11 by Eric Day
Removed purecov messages.
33
    return 0;
492.3.1 by Lee
break out item_real_func into functions directory
34
  str->set_real(nr,decimals, &my_charset_bin);
35
  return str;
36
}
37
38
39
my_decimal *Item_real_func::val_decimal(my_decimal *decimal_value)
40
{
41
  assert(fixed);
42
  double nr= val_real();
43
  if (null_value)
971.6.11 by Eric Day
Removed purecov messages.
44
    return 0;
492.3.1 by Lee
break out item_real_func into functions directory
45
  double2my_decimal(E_DEC_FATAL_ERROR, nr, decimal_value);
46
  return decimal_value;
47
}
48
572.1.4 by Monty Taylor
Removed a bunch of unusued tests and defines from autoconf.
49
int64_t Item_real_func::val_int()
50
{
51
  assert(fixed == 1);
52
  return (int64_t) rint(val_real());
53
}
54
55
void Item_real_func::fix_length_and_dec()
56
{
57
  decimals= NOT_FIXED_DEC;
58
  max_length= float_length(decimals);
59
}
492.3.1 by Lee
break out item_real_func into functions directory
60
1280.1.10 by Monty Taylor
Put everything in drizzled into drizzled namespace.
61
} /* namespace drizzled */