Drizzled Public API Documentation
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
minus.cc
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, Inc.
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
20
#include <config.h>
21
22
#include <drizzled/function/math/minus.h>
23
#include <drizzled/type/decimal.h>
24
25
namespace
drizzled
26
{
27
33
void
Item_func_minus::fix_length_and_dec
()
34
{
35
Item_num_op::fix_length_and_dec();
36
if
(unsigned_flag)
37
unsigned_flag= 0;
38
}
39
40
41
double
Item_func_minus::real_op
()
42
{
43
double
value= args[0]->
val_real
() - args[1]->
val_real
();
44
if
((
null_value
=args[0]->
null_value
|| args[1]->
null_value
))
45
return
0.0;
46
return
fix_result(value);
47
}
48
49
50
int64_t
Item_func_minus::int_op
()
51
{
52
int64_t value=args[0]->
val_int
() - args[1]->
val_int
();
53
if
((
null_value
=args[0]->
null_value
|| args[1]->
null_value
))
54
return
0;
55
return
value;
56
}
57
62
type::Decimal
*
Item_func_minus::decimal_op
(
type::Decimal
*decimal_value)
63
{
64
type::Decimal
value1, *val1;
65
type::Decimal
value2, *val2=
66
67
val1= args[0]->
val_decimal
(&value1);
68
if
((
null_value
= args[0]->
null_value
))
69
return
0;
70
val2= args[1]->
val_decimal
(&value2);
71
if
(!(
null_value
= (args[1]->
null_value
||
72
(class_decimal_sub(E_DEC_FATAL_ERROR, decimal_value, val1,
73
val2) > 3))))
74
return
decimal_value;
75
return
0;
76
}
77
78
}
/* namespace drizzled */
drizzled
function
math
minus.cc
Generated on Tue Oct 29 2013 17:05:36 for drizzle by
1.8.4