: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
***************************
BIT Functions and Operators
***************************
.. contents::
Bitwise Operator
================
A **Bitwise** operator performs operations in bits, and can be used in arithmetic operations. An integer type is specified as the operand and the **BIT** type cannot be specified. An integer of **BIGINT** type (64-bit integer) is returned as a result of the operation. If one or more operands are **NULL**, **NULL** is returned.
The following table shows the bitwise operators supported by CUBRID.
**The bitwise operators**
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------+----------------+----------------+
| Bitwise operator | Description | Expression | Return Value |
+======================+================================================================================================================================================+================+================+
| & | Performs AND operation in bits and returns a BIGINT integer. | 17 & 3 | 1 |
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------+----------------+----------------+
| \| | Performs OR operation in bits and returns a BIGINT integer. | 17 \| 3 | 19 |
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------+----------------+----------------+
| ^ | Performs XOR operation in bits and returns a BIGINT integer. | 17 ^ 3 | 18 |
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------+----------------+----------------+
| ~ | A unary operator. It performs complementary operation that reverses (INVERT) the bit order of the operand and returns a BIGINT integer. | ~17 | -18 |
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------+----------------+----------------+
| << | Performs the operation to shift bits of the left operand as far to the left as the value of the right operand, and returns a BIGINT integer. | 17 << 3 | 136 |
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------+----------------+----------------+
| >> | Performs the operation to shift bits of the left operand as far to the right as the value of the right operand, and returns a BIGINT integer. | 17 >> 3 | 2 |
+----------------------+------------------------------------------------------------------------------------------------------------------------------------------------+----------------+----------------+
BIT_AND
=======
.. function:: BIT_AND (expr)
As an aggregate function, it performs **AND** operations in bits on every bit of *expr*. The return value is a **BIGINT** type. If there is no row that satisfies the expression, **NULL** is returned.
:param expr: An expression of integer type
: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)
As an aggregate function, it performs **OR** operations in bits on every bit of *expr*. The return value is a **BIGINT** type. If there is no row that satisfies the expression, **NULL** is returned.
:param expr: An expression of integer type
: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)
As an aggregate function, it performs **XOR** operations in bits on every bit of *expr*. The return value is a **BIGINT** type. If there is no row that satisfies the expression, **NULL** is returned.
:param expr: An expression of integer type
: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)
The **BIT_COUNT** function returns the number of bits of *expr* that have been set to 1; it is not an aggregate function. The return value is a **BIGINT** type.
:param expr: An expression of integer type
:rtype: BIGINT
.. code-block:: sql
SELECT BIT_COUNT(id) FROM bit_tbl WHERE id in(1,3,5);
::
bit_count(id)
================
1
2
2
They went down to the water-side to try the effects of a bath in the surf as it rolled in from the Pacific Ocean. They found it refreshing, and were tempted to linger long in the foam-crested waves. Near by there was a fishing-place, where several Japanese were amusing themselves with rod and line, just as American boys and men take pleasure in the same way. Fish seemed to be abundant, as they were biting freely, and it took but a short time to fill a basket. In the little harbor formed between the island and the shore several junks and boats were at anchor, and in the foreground some smaller boats were moving about. There was not an American feature to the scene, and the boys were thoroughly delighted at this perfect picture of Japanese life. It was sea-life, too; and they had island and main, water and mountain, boats and houses, all in a single glance. "For our sick soldiers!" "Yes, I'm going to take that away with me to-day." "I destroyed it. There was no object in keeping it. I tore it up then and there and pitched it on the pavement. The motor was driven by a dumb man, who conveyed me to the corner house. It struck me as strange, but then the owner might have returned. When I got there I found the man subsequently murdered suffering from a combination of alcoholic poisoning and laudanum. It was hard work, but I managed to save him. A Spanish woman--the only creature besides my patient I saw--paid me a fee of three guineas, and there ends the matter." fatherly letter--but frank! He said he saw from the address that I ¡°Who are you, please?¡± Sandy shot the question out suddenly. He had gone back. "You'll come through all right," said the Surgeon smiling. "You're the right kind to live. You've got grit. I'll look at your partner now." 'he Took Another Look at his Heavy Revolver.' 254 But after the gun was gone, and after Shorty had written a laborious letter, informing Sammy of the shipment of the gun and its history, which letter inclosed a crisp greenback, and was almost as urgent in injunctions to Sammy to write as Sammy had been about his piece of ordnance, Shorty sat down in sadness of heart. He was famishing for information from Maria, and at the lowest calculation he could not hope for a letter from Sammy for two weeks. The firing and stone-throwing lasted an hour or more, and then seemed to die down from sheer exhaustion. Odiam had triumphed at last. Just when Reuben's unsettled allegiance should have been given entirely to the wife who had borne him a son, his farm had suddenly snatched from him all his thought, all his care, his love, and his anxiety, all that should have been hers. It seemed almost as if some malignant spirit had controlled events, and for Rose's stroke prepared a counter-stroke that should effectually drive her off the field. The same evening that Rose had gone weeping and shuddering upstairs, Reuben had interviewed the vet. from Rye and heard him say "excema epizootica." This had not conveyed much, so the vet. had translated brutally: "I don't ask for that to-night¡ªall I ask is food and shelter, same as you'd give to a dog." "Yes, yes, we will consider of some more fitting answer," said Leicester fiercely;¡ªand after consulting earnestly for a few minutes with Jack Straw, Thomas Sack, and other leaders, he returned to De Vere, and said¡ª HoMEÃâ·ÑÍøÕ¾Ò»¼¶ÊÓÆµ²¤ÂÜÃÛ
ENTER NUMBET 0018gzjunjie.com.cn
www.apksign.net.cn
asdxjsc.com.cn
www.yjqc.net.cn
dexinjy.com.cn
www.cfdtz.com.cn
www.pxne.com.cn
www.ishare.org.cn
wisolo.com.cn
www.1788888.com.cn