~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/functions/mod.cc

  • Committer: Monty Taylor
  • Date: 2008-11-16 20:15:33 UTC
  • mto: (584.1.9 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081116201533-d0f19s1bk1h95iyw
Removed a big bank of includes from item.h.

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 <drizzled/function/math/mod.h>
23
 
 
24
 
#include <algorithm>
25
 
 
26
 
using namespace std;
27
 
 
28
 
namespace drizzled
29
 
{
 
20
#include <drizzled/server_includes.h>
 
21
#include CSTDINT_H
 
22
#include <drizzled/functions/mod.h>
 
23
#include CMATH_H
 
24
 
 
25
#if defined(CMATH_NAMESPACE)
 
26
using namespace CMATH_NAMESPACE;
 
27
#endif
30
28
 
31
29
int64_t Item_func_mod::int_op()
32
30
{
36
34
  int64_t result;
37
35
 
38
36
  if ((null_value= args[0]->null_value || args[1]->null_value))
39
 
    return 0;
 
37
    return 0; /* purecov: inspected */
40
38
  if (val2 == 0)
41
39
  {
42
40
    signal_divide_by_null();
44
42
  }
45
43
 
46
44
  if (args[0]->unsigned_flag)
47
 
    result= args[1]->unsigned_flag ?
 
45
    result= args[1]->unsigned_flag ? 
48
46
      ((uint64_t) value) % ((uint64_t) val2) : ((uint64_t) value) % val2;
49
47
  else
50
48
    result= args[1]->unsigned_flag ?
59
57
  double value= args[0]->val_real();
60
58
  double val2=  args[1]->val_real();
61
59
  if ((null_value= args[0]->null_value || args[1]->null_value))
62
 
    return 0.0;
 
60
    return 0.0; /* purecov: inspected */
63
61
  if (val2 == 0.0)
64
62
  {
65
63
    signal_divide_by_null();
96
94
 
97
95
void Item_func_mod::result_precision()
98
96
{
99
 
  decimals= max(args[0]->decimals, args[1]->decimals);
100
 
  max_length= max(args[0]->max_length, args[1]->max_length);
 
97
  decimals= cmax(args[0]->decimals, args[1]->decimals);
 
98
  max_length= cmax(args[0]->max_length, args[1]->max_length);
101
99
}
102
100
 
103
101
 
108
106
  unsigned_flag= args[0]->unsigned_flag;
109
107
}
110
108
 
111
 
} /* namespace drizzled */