~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2009-09-30 07:01:32 UTC
  • mto: This revision was merged to the branch mainline in revision 1184.
  • Revision ID: mordred@inaugust.com-20090930070132-b1ol1xu1rpajdddy
Small namespace cleanup.

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
#include <drizzled/server_includes.h>
21
21
#include CSTDINT_H
22
 
#include <drizzled/functions/divide.h>
 
22
#include <drizzled/function/math/divide.h>
 
23
#include <drizzled/session.h>
 
24
 
 
25
#include <algorithm>
 
26
 
 
27
using namespace std;
23
28
 
24
29
double Item_func_div::real_op()
25
30
{
63
68
 
64
69
void Item_func_div::result_precision()
65
70
{
66
 
  uint32_t precision=cmin(args[0]->decimal_precision() + prec_increment,
67
 
                     (unsigned int)DECIMAL_MAX_PRECISION);
 
71
  uint32_t precision= min(args[0]->decimal_precision() + prec_increment,
 
72
                          (unsigned int)DECIMAL_MAX_PRECISION);
68
73
  /* Integer operations keep unsigned_flag if one of arguments is unsigned */
69
74
  if (result_type() == INT_RESULT)
70
75
    unsigned_flag= args[0]->unsigned_flag | args[1]->unsigned_flag;
71
76
  else
72
77
    unsigned_flag= args[0]->unsigned_flag & args[1]->unsigned_flag;
73
 
  decimals= cmin(args[0]->decimals + prec_increment, (unsigned int)DECIMAL_MAX_SCALE);
 
78
 
 
79
  decimals= min(args[0]->decimals + prec_increment, (unsigned int)DECIMAL_MAX_SCALE);
74
80
  max_length= my_decimal_precision_to_length(precision, decimals,
75
81
                                             unsigned_flag);
76
82
}
80
86
{
81
87
  prec_increment= current_session->variables.div_precincrement;
82
88
  Item_num_op::fix_length_and_dec();
83
 
  switch(hybrid_type) {
 
89
 
 
90
  switch(hybrid_type)
 
91
  {
84
92
  case REAL_RESULT:
85
93
  {
86
 
    decimals=cmax(args[0]->decimals,args[1]->decimals)+prec_increment;
 
94
    decimals= max(args[0]->decimals,args[1]->decimals)+prec_increment;
87
95
    set_if_smaller(decimals, NOT_FIXED_DEC);
88
 
    max_length=args[0]->max_length - args[0]->decimals + decimals;
89
 
    uint32_t tmp=float_length(decimals);
 
96
    max_length= args[0]->max_length - args[0]->decimals + decimals;
 
97
    uint32_t tmp= float_length(decimals);
90
98
    set_if_smaller(max_length,tmp);
91
99
    break;
92
100
  }