~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Stewart Smith
  • Date: 2009-07-02 17:18:18 UTC
  • mfrom: (1085 staging)
  • mto: This revision was merged to the branch mainline in revision 1089.
  • Revision ID: stewart@flamingspork.com-20090702171818-qrp4d403iw8tazlg
mergeĀ mainline

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
#include <drizzled/function/math/round.h>
22
22
 
23
23
#include <limits>
 
24
#include <algorithm>
24
25
 
25
26
using namespace std;
26
27
 
55
56
  if (args[0]->decimals == NOT_FIXED_DEC)
56
57
  {
57
58
    max_length= args[0]->max_length;
58
 
    decimals= cmin(decimals_to_set, NOT_FIXED_DEC);
 
59
    decimals= min(decimals_to_set, (int)NOT_FIXED_DEC);
59
60
    hybrid_type= REAL_RESULT;
60
61
    return;
61
62
  }
64
65
  case REAL_RESULT:
65
66
  case STRING_RESULT:
66
67
    hybrid_type= REAL_RESULT;
67
 
    decimals= cmin(decimals_to_set, NOT_FIXED_DEC);
 
68
    decimals= min(decimals_to_set, (int)NOT_FIXED_DEC);
68
69
    max_length= float_length(decimals);
69
70
    break;
70
71
  case INT_RESULT:
81
82
  case DECIMAL_RESULT:
82
83
  {
83
84
    hybrid_type= DECIMAL_RESULT;
84
 
    decimals_to_set= cmin(DECIMAL_MAX_SCALE, decimals_to_set);
 
85
    decimals_to_set= min(DECIMAL_MAX_SCALE, decimals_to_set);
85
86
    int decimals_delta= args[0]->decimals - decimals_to_set;
86
87
    int precision= args[0]->decimal_precision();
87
88
    int length_increase= ((decimals_delta <= 0) || truncate) ? 0:1;
88
89
 
89
90
    precision-= decimals_delta - length_increase;
90
 
    decimals= cmin(decimals_to_set, DECIMAL_MAX_SCALE);
 
91
    decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
91
92
    max_length= my_decimal_precision_to_length(precision, decimals,
92
93
                                               unsigned_flag);
93
94
    break;
204
205
{
205
206
  my_decimal val, *value= args[0]->val_decimal(&val);
206
207
  int64_t dec= args[1]->val_int();
 
208
 
207
209
  if (dec >= 0 || args[1]->unsigned_flag)
208
 
    dec= cmin(dec, (int64_t) decimals);
 
210
    dec= min(dec, (int64_t) decimals);
209
211
  else if (dec < INT_MIN)
210
212
    dec= INT_MIN;
211
213