Binary Literals

Binary literals can be written in one of the following formats: b'value', B'value' or 0bvalue, where value is a string composed by 0 and 1 digits.

Binary literals are interpreted as binary strings, and are convenient to represent VARBINARY, BINARY or BIT values.

To convert a binary literal into an integer, just add 0.


Printing the value as a binary string:

SELECT 0b1000001;
| 0b1000001 |
| A         |

Converting the same value into a number:

SELECT 0b1000001+0;
| 0b1000001+0 |
|          65 |

See Also


Comments loading...
Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.