Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[doc](function)support bit_test function #1214

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions docs/sql-manual/sql-functions/bitwise-functions/bit_test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
---
{
"title": "BIT_TEST",
"language": "en"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

## bit_test
### description
#### Syntax

`bit_test(Integer-type value, Integer-type pos, '......')`

"Convert the value of 'value' into binary form and return the value at the specified position 'pos', where 'pos' starts from 0 and goes from right to left. If there are multiple values for 'pos', combine the values at multiple 'pos' positions using the AND operator and return the final result.
If the value of pos is negative or exceeds the total number of bits in value, the result will be 0.
Integer value ranges: TINYINT, SMALLINT, INT, BIGINT, LARGEINT."

### example

### example

mysql [(none)]>SELECT bit_test(43, 1);
+-----------------+
| bit_test(43, 1) |
+-----------------+
| 1 |
+-----------------+

mysql [(none)]>select bit_test(43,-1);
+------------------+
| bit_test(43, -1) |
+------------------+
| 0 |
+------------------+

mysql [(none)]>SELECT bit_test(43, 0, 1, 3, 5,2);
+-----------------------------+
| bit_test(43, 0, 1, 3, 5, 2) |
+-----------------------------+
| 0 |
+-----------------------------+
```

### keywords

bit_test,bit_test_all
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
{
"title": "BIT_TEST",
"language": "zh-CN"
}
---

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->

## bit_test
### description
#### Syntax

`bit_test(Integer-type value, Integer-type pos, '......')`

将value的值转换为二进制的形式,返回指定位置pos的值,pos从0开始,从右到左。
如果pos 有多个值,则将多个pos位置上的值用与运算符结合起来,返回最终结果。
如果pos 的取值为负数或者超过value的bit位总数,则会返回结果为0.
整数value范围:TINYINT、SMALLINT、INT、BIGINT、LARGEINT

### example

mysql [(none)]>SELECT bit_test(43, 1);
+-----------------+
| bit_test(43, 1) |
+-----------------+
| 1 |
+-----------------+

mysql [(none)]>select bit_test(43,-1);
+------------------+
| bit_test(43, -1) |
+------------------+
| 0 |
+------------------+

mysql [(none)]>SELECT bit_test(43, 0, 1, 3, 5,2);
+-----------------------------+
| bit_test(43, 0, 1, 3, 5, 2) |
+-----------------------------+
| 0 |
+-----------------------------+
```

### keywords

bit_test,bit_test_all
1 change: 1 addition & 0 deletions sidebars.json
Original file line number Diff line number Diff line change
Expand Up @@ -1063,6 +1063,7 @@
"label": "Bitwise Functions",
"items": [
"sql-manual/sql-functions/bitwise-functions/bitand",
"sql-manual/sql-functions/bitwise-functions/bit_test",
"sql-manual/sql-functions/bitwise-functions/bitor",
"sql-manual/sql-functions/bitwise-functions/bitxor",
"sql-manual/sql-functions/bitwise-functions/bitnot",
Expand Down
Loading