---
title: bit_reverse function
description: Learn the syntax of the bit\_reverse function of the SQL language in Databricks SQL and Databricks Runtime.
canonical_url: https://docs.databricks.com/aws/en/sql/language-manual/functions/bit_reverse
---

# `bit_reverse` function

**Applies to:** ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks SQL ![check marked yes](https://docs.databricks.com/aws/en/images/icons/check.png) Databricks Runtime

Returns the value obtained by reversing the order of the bits in the two's complement binary representation of the specified integral value.

## Syntax

```
bit_reverse(expr)
```

## Arguments

* `expr`: An expression that evaluates to an integral numeric.

## Returns

The result type matches the argument type.

## Examples

```sql
> SELECT bit_reverse(64Y);
 2
> SELECT bit_reverse(64L);
 144115188075855872
> SELECT bit_reverse(-1);
-1
> SELECT bit_reverse(-2);
2147483647
```

## Related functions

* [`bit_get` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/bit_get.md)
* [`getbit` function](https://docs.databricks.com/aws/en/sql/language-manual/functions/getbit.md)
* [`~` (tilde sign) operator](https://docs.databricks.com/aws/en/sql/language-manual/functions/tildesign.md)
