~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/function/math/neg.cc

  • Committer: Padraig O'Sullivan
  • Date: 2009-09-18 00:22:38 UTC
  • mto: This revision was merged to the branch mainline in revision 1139.
  • Revision ID: osullivan.padraig@gmail.com-20090918002238-zq7mui4r2yzoidz1
Extracted KeyUse into its own header file and placed it within the
drizzled::optimizer namespace.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
2
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
3
 *
4
 
 *  Copyright (C) 2008 Sun Microsystems, Inc.
 
4
 *  Copyright (C) 2008 Sun Microsystems
5
5
 *
6
6
 *  This program is free software; you can redistribute it and/or modify
7
7
 *  it under the terms of the GNU General Public License as published by
17
17
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
18
 */
19
19
 
20
 
#include "config.h"
21
 
 
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
22
22
#include <drizzled/function/math/neg.h>
23
23
 
24
 
namespace drizzled
25
 
{
26
 
 
27
24
double Item_func_neg::real_op()
28
25
{
29
26
  double value= args[0]->val_real();
36
33
{
37
34
  int64_t value= args[0]->val_int();
38
35
  null_value= args[0]->null_value;
39
 
 
40
36
  return -value;
41
37
}
42
38
 
43
39
 
44
 
type::Decimal *Item_func_neg::decimal_op(type::Decimal *decimal_value)
 
40
my_decimal *Item_func_neg::decimal_op(my_decimal *decimal_value)
45
41
{
46
 
  type::Decimal val, *value= args[0]->val_decimal(&val);
 
42
  my_decimal val, *value= args[0]->val_decimal(&val);
47
43
  if (!(null_value= args[0]->null_value))
48
44
  {
49
 
    class_decimal2decimal(value, decimal_value);
50
 
    class_decimal_neg(decimal_value);
 
45
    my_decimal2decimal(value, decimal_value);
 
46
    my_decimal_neg(decimal_value);
51
47
    return decimal_value;
52
48
  }
53
49
  return 0;
86
82
      hybrid_type= DECIMAL_RESULT;
87
83
    }
88
84
  }
89
 
  unsigned_flag= false;
 
85
  unsigned_flag= 0;
 
86
  return;
90
87
}
91
 
 
92
 
} /* namespace drizzled */