---
schema_version: "1"
id: 5a2956d222095da2fc3b45e9c92c853675025f1de96b1d3a0f1a0fbe773545b7
title: BINARY_QUANTIZE
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/data-cloud/data-cloud-query-guide/references/data-cloud-sql-reference/scalar-func/array-func/binary-quantize.md
canonical_url: https://developer.salesforce.com/docs/data/data-cloud-query-guide/references/dc-sql-reference/binary-quantize.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 774e3cc4559cc6ea614cce41d77e63155f78ecc92a6fae2a340340898b57a099
products:
  - Data 360 Query Guide
  - Data 360 Developer Documentation
---
# `BINARY_QUANTIZE`

**Applies to:** ✅ Data 360 SQL ✅ Tableau Hyper API

Encodes each array element into a single bit, compressing the vector by approximately 32x.

## Syntax

```sql
binary_quantize(<array>)
```

## Arguments

### Required

- `<array>`: The vector to quantize (`array(real)` or `array(double-precision)`).

## Returns

Returns a bytea value where each bit represents whether the corresponding array element is greater than 0 (1) or not (0).

## Considerations

- Elements greater than 0 are encoded as 1, all others (including 0 and negative values) as 0.
- The compression ratio is approximately 32x.

## Examples

### Quantize a Vector

Convert a numeric vector to binary representation.

```sql
SELECT binary_quantize(ARRAY[-5, -3, 2, 6]) AS result;
```

Returns `'0011'`, where negative values become 0 and positive values become 1.

## Related Documentation

- [Array Data Type](https://developer.salesforce.com/docs/data/data-cloud-query-guide/datatype/array.md)
