1
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
4
* Copyright (C) 2008 Sun Microsystems, Inc.
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; version 2 of the License.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program; if not, write to the Free Software
17
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22
#include <drizzled/function/bit/functions.h>
33
int64_t ShiftLeft::val_int()
37
uint64_t res= ((uint64_t) args[0]->val_int() <<
38
(shift=(uint) args[1]->val_int()));
39
if (args[0]->null_value || args[1]->null_value)
46
return (shift < sizeof(int64_t)*8 ? (int64_t) res : 0LL);
49
int64_t ShiftRight::val_int()
53
uint64_t res= (uint64_t) args[0]->val_int() >>
54
(shift=(uint) args[1]->val_int());
56
if (args[0]->null_value || args[1]->null_value)
63
return (shift < sizeof(int64_t)*8 ? (int64_t) res : 0LL);
67
int64_t Neg::val_int()
70
uint64_t res= (uint64_t) args[0]->val_int();
72
if ((null_value=args[0]->null_value))
79
int64_t Xor::val_int()
82
uint64_t arg1= (uint64_t) args[0]->val_int();
83
uint64_t arg2= (uint64_t) args[1]->val_int();
85
if ((null_value= (args[0]->null_value || args[1]->null_value)))
88
return (int64_t) (arg1 ^ arg2);
95
uint64_t arg1= (uint64_t) args[0]->val_int();
96
if (args[0]->null_value)
98
null_value=1; /* purecov: inspected */
99
return 0; /* purecov: inspected */
102
uint64_t arg2= (uint64_t) args[1]->val_int();
103
if (args[1]->null_value)
110
return (int64_t) (arg1 | arg2);
113
int64_t And::val_int()
117
uint64_t arg1= (uint64_t) args[0]->val_int();
119
if (args[0]->null_value)
121
null_value=1; /* purecov: inspected */
122
return 0; /* purecov: inspected */
125
uint64_t arg2= (uint64_t) args[1]->val_int();
127
if (args[1]->null_value)
129
null_value=1; /* purecov: inspected */
130
return 0; /* purecov: inspected */
134
return (int64_t) (arg1 & arg2);
137
} /* namespace bit */
138
} /* namespace function */
139
} // namespace drizzled