Quantization Scale and Zero Point Calculator
Calculate affine quantization scale and zero point from a real-value range and a quantized integer range. Enter the minimum and maximum values for both ranges to determine the parameters required for linear quantization.
Zero point = round(quant_min – real_min / scale)
What Are Quantization Scale and Zero Point?
Scale and zero point are parameters used in affine quantization to map a continuous or floating-point numerical range onto a finite set of integer codes.
The scale determines the size of one quantized step in real-value units. The zero point identifies the integer code corresponding approximately to real zero.
Quantization Scale Formula
The scale is calculated by dividing the size of the real-value interval by the size of the quantized integer interval.
For a real range from -1 to 1 and an integer range from -128 to 127:
1 – (-1) = 2
Integer span:
127 – (-128) = 255
Scale:
2 / 255
≈ 0.0078431373
Zero Point Formula
After the scale is known, the affine zero point can be calculated from the minimum endpoints:
Because the zero point must represent an integer code, the calculated value is rounded to the nearest integer and then restricted to the supplied quantized range if necessary.
Scale and Zero Point Example
-1 to 1
Quantized range:
-128 to 127
Scale:
2 / 255
≈ 0.0078431373
Raw zero point:
-128 – (-1 / 0.0078431373)
≈ -0.5
Rounded zero point:
0
What Does the Scale Represent?
Scale describes the real-value distance between neighboring integer codes.
If the scale is 0.01, increasing the quantized code by one represents approximately 0.01 units in the original real-value domain.
Difference of one integer code:
1 × 0.01
= 0.01 real units
What Does the Zero Point Represent?
The zero point specifies which integer code corresponds to real zero under affine quantization.
When a real range is not symmetric around zero, the zero point may be significantly different from zero.
means:
quantized code 25
represents approximately real value 0
Why Is the Zero Point Rounded?
Quantized storage uses integer codes. The mathematical zero-point calculation may produce a fractional result, but a fractional integer code cannot be stored.
The result is therefore rounded to the nearest integer and constrained to the available quantized range.
Common Quantized Integer Ranges
| Representation | Minimum | Maximum | Levels |
|---|---|---|---|
| Signed INT8 | -128 | 127 | 256 |
| Unsigned UINT8 | 0 | 255 | 256 |
| Signed INT4 | -8 | 7 | 16 |
| Unsigned UINT4 | 0 | 15 | 16 |
Why These Parameters Matter
Range Mapping
Scale defines how the original numerical interval is distributed across the available integer codes.
Real Zero
Zero point allows real zero to map accurately or approximately into an integer representation.
Low-Precision Storage
The parameters enable compact integer representations to stand in for higher-precision numerical values.
Machine Learning
Scale and zero point are commonly used in affine quantization workflows for low-precision inference.
Important Calculation Notes
The real maximum must be greater than the real minimum.
The quantized maximum must be greater than the quantized minimum.
Quantized minimum and maximum must be whole integers.
Scale is always positive when both ranges are entered correctly.
The mathematical zero point may be fractional before rounding.
The final zero point is rounded to an integer and clamped to the supplied quantized range.