~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2010-10-27 21:00:49 UTC
  • mto: This revision was merged to the branch mainline in revision 1886.
  • Revision ID: brian@tangent.org-20101027210049-zfpgx2cfbrh8maq9
A couple of fixes to documentation.

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
100
100
 
101
101
    precision-= decimals_delta - length_increase;
102
102
    decimals= min(decimals_to_set, DECIMAL_MAX_SCALE);
103
 
    max_length= class_decimal_precision_to_length(precision, decimals,
 
103
    max_length= my_decimal_precision_to_length(precision, decimals,
104
104
                                               unsigned_flag);
105
105
    break;
106
106
  }
203
203
 
204
204
  if (truncate)
205
205
    value= (unsigned_flag) ?
206
 
      (int64_t)(((uint64_t) value / tmp) * tmp) : (value / tmp) * tmp;
 
206
      ((uint64_t) value / tmp) * tmp : (value / tmp) * tmp;
207
207
  else
208
208
    value= (unsigned_flag || value >= 0) ?
209
 
      (int64_t)(my_unsigned_round((uint64_t) value, tmp)) :
 
209
      my_unsigned_round((uint64_t) value, tmp) :
210
210
      -(int64_t) my_unsigned_round((uint64_t) -value, tmp);
211
211
  return value;
212
212
}
213
213
 
214
214
 
215
 
type::Decimal *Item_func_round::decimal_op(type::Decimal *decimal_value)
 
215
my_decimal *Item_func_round::decimal_op(my_decimal *decimal_value)
216
216
{
217
 
  type::Decimal val, *value= args[0]->val_decimal(&val);
 
217
  my_decimal val, *value= args[0]->val_decimal(&val);
218
218
  int64_t dec= args[1]->val_int();
219
219
 
220
220
  if (dec >= 0 || args[1]->unsigned_flag)
223
223
    dec= INT_MIN;
224
224
 
225
225
  if (!(null_value= (args[0]->null_value || args[1]->null_value ||
226
 
                     class_decimal_round(E_DEC_FATAL_ERROR, value, (int) dec,
 
226
                     my_decimal_round(E_DEC_FATAL_ERROR, value, (int) dec,
227
227
                                      truncate, decimal_value) > 1)))
228
228
  {
229
229
    decimal_value->frac= decimals;