BIT_LENGTH
Descriptionβ
It is used to return the median of the binary representation of a string (that is, the total number of binary digits). It calculates the number of bits occupied by the binary encoding of the string.
Syntaxβ
BIT_LENGTH( <str>)
Parametersβ
parameter | description |
---|---|
<str> | The string to be calculated |
Return Valueβ
Returns the number of bits occupied by <str>
in the binary representation, including all 0 and 1.
Examplesβ
select BIT_LENGTH("abc"), BIT_LENGTH("δΈε½"), BIT_LENGTH(123);
+-------------------+----------------------+-----------------------------------------+
| bit_length('abc') | bit_length('δΈε½') | bit_length(cast(123 as VARCHAR(65533))) |
+-------------------+----------------------+-----------------------------------------+
| 24 | 48 | 24 |
+-------------------+----------------------+-----------------------------------------+