Principle:ClickHouse ClickHouse BFloat16 Type
| Knowledge Sources | |
|---|---|
| Domains | Numeric_Types, Data_Types |
| Last Updated | 2026-02-08 00:00 GMT |
Overview
A 16-bit floating point format that prioritizes dynamic range over precision by sharing the exponent width with 32-bit floats.
Description
`BFloat16` (Brain Float16) is a floating point format designed for machine learning and numerical computing. Unlike the standard IEEE 754 half-precision format (`Float16`), which has 5 exponent bits and 10 mantissa bits, `BFloat16` has 8 exponent bits and 7 mantissa bits. This gives it the same dynamic range as `Float32` while using half the storage. The key insight is that many AI workloads benefit more from range than precision - they can tolerate lower precision as long as they can represent very large and very small numbers.
A unique property of `BFloat16` is that its bit representation matches the most significant 16 bits of a `Float32` value. This enables trivial conversions: to convert `Float32` to `BFloat16`, simply take the upper 16 bits. To convert back, shift left by 16 bits and pad with zeros.
Usage
Use `BFloat16` when you need memory-efficient floating point storage for AI/ML applications, neural network inference, vector embeddings, or quantized model weights. Choose `BFloat16` over `Float16` when the range of values is more important than precision. Choose regular `Float32` when you need full precision for financial calculations or scientific computing.
Theoretical Basis
The format consists of:
- 1 sign bit
- 8 exponent bits (same as `Float32`)
- 7 mantissa bits (reduced from `Float32`'s 23 bits)
The value is computed as: `(-1)^sign × 2^(exponent - 127) × (1 + mantissa/128)`
Dynamic range: approximately 10^-38 to 10^38 (same as `Float32`)
Precision: approximately 2-3 decimal digits (vs 7 for `Float32`)
This tradeoff is optimal for neural networks, where maintaining the ability to represent gradient magnitudes across many orders of magnitude is more important than having high precision in any particular value.