Skip to main content

BIN

Description

Converts decimal numbers to binary text.

Syntax

BIN(<a>)

Parameters

ParameterDescription
<a>Decimal value to be converted (type: BigInt)

Return Value

The binary representation of the parameter <a>. When <a> is negative, the result is its 64-bit complement. When a is NULL, returns NULL.

Examples

select bin(0);
+--------+
| bin(0) |
+--------+
| 0 |
+--------+
select bin(-1);
+------------------------------------------------------------------+
| bin(-1) |
+------------------------------------------------------------------+
| 1111111111111111111111111111111111111111111111111111111111111111 |
+------------------------------------------------------------------+
select bin(123);
+----------+
| bin(123) |
+----------+
| 1111011 |
+----------+
select bin(NULL);
+-----------+
| bin(NULL) |
+-----------+
| NULL |
+-----------+