9.6. Bit String Functions and Operators

9.6. Bit String Functions and Operators
9.6.位串函数和操作符
This section describes functions and operators for examining and manipulating bit strings, that is values of the types bit and bit varying. Aside from the usual comparison operators, the operators shown in Table 9.13 can be used. Bit string operands of &, |, and # must be of equal length. When bit shifting, the original length of the string is preserved, as shown in the examples.
本节介绍用于检查和操作位字符串(即位和位变化类型的值)的函数和运算符。 除了通常的比较运算符外,还可以使用表9.13中所示的运算符。 &,|和#的位字符串操作数必须具有相等的长度。 如示例所示,当进行位移时,将保留字符串的原始长度。
 
 

The following SQL-standard functions work on bit strings as well as character strings: length,bit_length, octet_length, position, substring, overlay.
以下SQL标准函数对位字符串和字符串均有效:length,bit_length, octet_length, position, substring, overlay
 
The following functions work on bit strings as well as binary strings: get_bit, set_bit. When working with a bit string, these functions number the first (leftmost) bit of the string as bit 0.
以下函数对位字符串和二进制字符串均起作用:get_bit,set_bit。 当使用位字符串时,这些函数将字符串的第一个(最左边)的位编号为0。
 
In addition, it is possible to cast integral values to and from type bit. Some examples:
另外,可以在类型bit之间进行整数值转换。 示例:
 
44::bit(10) 0000101100
44::bit(3) 100
cast(-44 as bit(12)) 111111010100
'1110'::bit(4)::integer 14
 
Note that casting to just “bit” means casting to bit(1), and so will deliver only the least significant bit of the integer.
请注意,强制转换为“ bit”意味着强制转换为bit(1),因此将仅传递整数的最低有效位。
 
Note
Casting an integer to bit(n) copies the rightmost n bits. Casting an integer to a bit string width wider than the integer itself will sign-extend on the left.
将整数强制转换为bit(n)会复制最右边的n位。 将整数强制转换为比整数本身宽的位字符串宽度,将在其左侧扩展。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值