2020-03-20 18:20:59 +00:00
|
|
|
|
# 位操作函数 {#wei-cao-zuo-han-shu}
|
2019-05-05 17:38:05 +00:00
|
|
|
|
|
|
|
|
|
位操作函数适用于UInt8,UInt16,UInt32,UInt64,Int8,Int16,Int32,Int64,Float32或Float64中的任何类型。
|
|
|
|
|
|
|
|
|
|
结果类型是一个整数,其位数等于其参数的最大位。如果至少有一个参数为有符数字,则结果为有符数字。如果参数是浮点数,则将其强制转换为Int64。
|
|
|
|
|
|
2020-04-08 14:22:25 +00:00
|
|
|
|
## bitAnd(a,b) {#bitanda-b}
|
2019-05-05 17:38:05 +00:00
|
|
|
|
|
2020-04-08 14:22:25 +00:00
|
|
|
|
## bitOr(a,b) {#bitora-b}
|
2019-05-05 17:38:05 +00:00
|
|
|
|
|
2020-04-08 14:22:25 +00:00
|
|
|
|
## bitXor(a,b) {#bitxora-b}
|
2019-05-05 17:38:05 +00:00
|
|
|
|
|
2020-03-20 18:20:59 +00:00
|
|
|
|
## bitNot(a) {#bitnota}
|
2019-05-05 17:38:05 +00:00
|
|
|
|
|
2020-04-08 14:22:25 +00:00
|
|
|
|
## bitShiftLeft(a,b) {#bitshiftlefta-b}
|
2019-05-05 17:38:05 +00:00
|
|
|
|
|
2020-04-08 14:22:25 +00:00
|
|
|
|
## bitShiftRight(a,b) {#bitshiftrighta-b}
|
2019-05-05 17:38:05 +00:00
|
|
|
|
|
2020-04-08 14:22:25 +00:00
|
|
|
|
## bitRotateLeft(a,b) {#bitrotatelefta-b}
|
2019-05-05 17:38:05 +00:00
|
|
|
|
|
2020-04-08 14:22:25 +00:00
|
|
|
|
## bitRotateRight(a,b) {#bitrotaterighta-b}
|
2019-05-05 17:38:05 +00:00
|
|
|
|
|
2020-04-08 14:22:25 +00:00
|
|
|
|
## bitTest(a,b) {#bittesta-b}
|
2019-05-05 17:38:05 +00:00
|
|
|
|
|
2020-04-08 14:22:25 +00:00
|
|
|
|
## bitTestAll(a,b) {#bittestalla-b}
|
2019-05-05 17:38:05 +00:00
|
|
|
|
|
2020-04-08 14:22:25 +00:00
|
|
|
|
## bitTestAny(a,b) {#bittestanya-b}
|
2019-05-05 17:38:05 +00:00
|
|
|
|
|
2021-09-19 20:05:54 +00:00
|
|
|
|
[来源文章](https://clickhouse.com/docs/en/query_language/functions/bit_functions/) <!--hide-->
|