~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2009-02-21 00:18:15 UTC
  • Revision ID: brian@tangent.org-20090221001815-x20e8h71e984lvs1
Completion (?) of uint conversion.

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
 
#include <math.h>
22
 
#include "ceiling.h"
23
 
#include <drizzled/type/decimal.h>
24
 
 
25
 
namespace drizzled
26
 
{
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
 
22
#include <drizzled/function/math/ceiling.h>
 
23
#include CMATH_H
 
24
 
 
25
#if defined(CMATH_NAMESPACE)
 
26
using namespace CMATH_NAMESPACE;
 
27
#endif
 
28
 
27
29
 
28
30
int64_t Item_func_ceiling::int_op()
29
31
{
35
37
    break;
36
38
  case DECIMAL_RESULT:
37
39
  {
38
 
    type::Decimal dec_buf, *dec;
 
40
    my_decimal dec_buf, *dec;
39
41
    if ((dec= Item_func_ceiling::decimal_op(&dec_buf)))
40
 
      dec->val_int32(E_DEC_FATAL_ERROR, unsigned_flag, &result);
 
42
      my_decimal2int(E_DEC_FATAL_ERROR, dec, unsigned_flag, &result);
41
43
    else
42
44
      result= 0;
43
45
    break;
59
61
  return ceil(value);
60
62
}
61
63
 
62
 
type::Decimal *Item_func_ceiling::decimal_op(type::Decimal *decimal_value)
 
64
my_decimal *Item_func_ceiling::decimal_op(my_decimal *decimal_value)
63
65
{
64
 
  type::Decimal val, *value= args[0]->val_decimal(&val);
 
66
  my_decimal val, *value= args[0]->val_decimal(&val);
65
67
  if (!(null_value= (args[0]->null_value ||
66
 
                     class_decimal_ceiling(E_DEC_FATAL_ERROR, value,
 
68
                     my_decimal_ceiling(E_DEC_FATAL_ERROR, value,
67
69
                                        decimal_value) > 1)))
68
70
    return decimal_value;
69
71
  return 0;
70
72
}
71
73
 
72
 
} /* namespace drizzled */