~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

Merge Nathan

Show diffs side-by-side

added added

removed removed

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