:meta-keywords: CUBRID bitwise operator, cubrid bit_and, cubrid bit_or, cubrid bit_xor, cubrid bit_count
:meta-description: A Bitwise operator performs operations in bits, and can be used in arithmetic operations.
:tocdepth: 3
******************
비트 함수와 연산자
******************
.. contents::
비트 연산자
===========
비트 연산자(Bitwise operator)는 비트 단위로 연산을 수행하며 산술 연산식에서 이용될 수 있다. 피연산자로 정수 타입이 지정되며, **BIT** 타입은 지정될 수 없다. 연산 결과로 **BIGINT** 타입 정수(64비트 정수)를 반환한다. 이때, 하나 이상의 피연산자가 **NULL** 이면 **NULL** 을 반환한다.
아래는 CUBRID가 지원하는 비트 연산자의 종류에 관한 표이다.
**비트 연산자**
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------+----------------+------------------+
| 비트 연산자 | 설명 | 조건식 | 리턴 값 |
+======================+================================================================================================================================================+================+==================+
| & | 비트 단위로 **AND** 연산을 수행하고, **BIGINT** 정수를 반환한다. | 17 & 3 | 1 |
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------+----------------+------------------+
| \| | 비트 단위로 **OR** 연산을 수행하고, **BIGINT** 정수를 반환한다. | 17 \| 3 | 19 |
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------+----------------+------------------+
| ^ | 비트 단위로 **XOR** 연산을 수행하고, **BIGINT** 정수를 반환한다. | 17 ^ 3 | 18 |
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------+----------------+------------------+
| ~ | 단항 연산자이며, 피연산자의 비트를 역으로 전환(**INVERT**)하는 보수 연산을 수행하고, **BIGINT** 정수를 반환한다. | ~17 | -18 |
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------+----------------+------------------+
| << | 왼쪽 피연산자의 비트를 오른쪽 피연산자만큼 왼쪽으로 이동시키는 연산을 수행하고, **BIGINT** 정수를 반환한다. | 17 << 3 | 136 |
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------+----------------+------------------+
| >> | 왼쪽 피연산자의 비트를 오른쪽 피연산자만큼 오른쪽으로 이동시키는 연산을 수행하고, **BIGINT** 정수를 반환한다. | 17 >> 3 | 2 |
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------+----------------+------------------+
BIT_AND
=======
.. function:: BIT_AND (expr)
집계 함수로서, *expr* 의 모든 비트에 대해 비트 단위 **AND** 연산을 수행한다. 조건절을 만족하는 행이 없는 경우, NULL 을 반환한다.
:param expr: 정수 타입의 임의의 연산식이다.
:rtype: BIGINT
.. code-block:: sql
CREATE TABLE bit_tbl(id int);
INSERT INTO bit_tbl VALUES (1), (2), (3), (4), (5);
SELECT 1&3&5, BIT_AND(id) FROM bit_tbl WHERE id in(1,3,5);
::
1&3&5 bit_and(id)
============================================
1 1
BIT_OR
======
.. function:: BIT_OR (expr)
집계 함수로서, *expr* 의 모든 비트에 대해 비트 단위 **OR** 연산을 수행한다. 조건절을 만족하는 행이 없는 경우, **NULL** 을 반환한다.
:param expr: 정수 타입의 임의의 연산식이다.
:rtype: BIGINT
.. code-block:: sql
SELECT 1|3|5, BIT_OR(id) FROM bit_tbl WHERE id in(1,3,5);
::
1|3|5 bit_or(id)
============================================
7 7
BIT_XOR
=======
.. function:: BIT_XOR (expr)
집계 함수로서, *expr* 의 모든 비트에 대해 비트 단위 **XOR** 연산을 수행한다. 조건절을 만족하는 행이 없는 경우, **NULL** 을 반환한다.
:param expr: 정수 타입의 임의의 연산식이다.
:rtype: BIGINT
.. code-block:: sql
SELECT 1^2^3, BIT_XOR(id) FROM bit_tbl WHERE id in(1,3,5);
::
1^3^5 bit_xor(id)
============================================
7 7
BIT_COUNT
=========
.. function:: BIT_COUNT (expr)
*expr*\의 모든 비트 중 1로 설정된 비트의 개수를 반환하는 함수이며, 집계 함수는 아니다.
:param expr: 정수 타입의 임의의 연산식이다.
:rtype: BIGINT
.. code-block:: sql
SELECT BIT_COUNT(id) FROM bit_tbl WHERE id in(1,3,5);
::
bit_count(id)
================
1
2
2
Day widened into its first perfection as we moved down the highroad toward a near fork whose right was to lead Harry and his solemn cortge southward, while the left should be our eastward course. Camille and I rode horseback, side by side, with no one near enough to smile at my sentimental laudations of the morning's splendors, or at her for repaying my eloquence with looks so full of tender worship, personal acceptance and self-bestowal, that to tell of them here would make as poor a show as to lift a sea-flower out of the sea; they call for piccolo notes and I am no musician. The little man elected to have a cab. When Bow Street was reached Prout had the satisfaction of finding that all his birds had been netted. He received the warm congratulations of his inspector modestly. Caloric or air engines. I did not feel very comfortable after what had happened to those soldiers who lost their lives so cruelly sudden, or in any case had been seriously wounded, while the officers took little notice of them. But it was desirable to behave as discreetly as possible, and so to get a permit to Maastricht. "Louvain, It will check up, that way, too, smiled Larry. "Me run away," thought Shorty, as they walked along. "Hosses couldn't drag me away. I only hope that house is 10 miles off." Reuben began to take off his coatyoung Realf drew back almost in disgust. "Well, would Robert have stolen money, or Albert disgraced your name, to get free, if you and your farm hadn't made them slaves? If you hadn't been a heartless slave-driver would George have died the other night alone on the Moor?or would Richard have taken advantage of a neighbour's charity to escape from you? Don't you see that your ambition has driven you to make slaves of your children?" "D?an't tell me," said Coalbran in the bar, "as it wurn't his fault. Foot-and-mouth can't just drop from heaven. He must have bought some furriners, and they've carried it wud 'em, surelye." But meantime a strange restlessness consumed her, tinctured by a horrible boldness. There were moments when she no longer was afraid of Handshut, when she felt herself impelled to seek him out, and make the most of the short time they had together. There could be no danger, for he was going so soon ... so few more words, so few more glances.... Thus her mind worked. "What mean you, woman?" quickly returned De Boteler; "do you accuse the keeper of my chase as having plotted against your son, or whom do you suspect?" Her face was shrivelled and yellow, and the dark full eyes that now, as it were, stood forth from the sunken cheeks, looked with a strange brightness on the scene, and seemed well adapted to stamp the character of witch on so withered a form. And perhaps there were few of those entirely uninterested in the matter who now gazed upon her, who would not have sworn that she merited the stake. "Thou art set over the people, and to the Lord's anointed I come to seek for justice." HoMEŷһëƬѸպ
ENTER NUMBET 0018www.ysxxy.com.cn
www.cqpdsj.com.cn
b050.com.cn
huipos.com.cn
www.sheemin999.com.cn
cxdk.org.cn
matexs.com.cn
www.51axz.com.cn
www.golfly.com.cn
yzsjcsdj.com.cn