How to use the Shared exponent Calculator tool
- Enter the numbers in the Values box, separated by commas, spaces or line breaks.
- Set Mantissa bits to the signed width of each mantissa, a whole number from 2 to 32.
- Select Calculate. The Example button runs -13, 0.75, 3.5 with 8 mantissa bits.
- Read the Shared exponent line, then the Mantissas line, which lists one integer per input value in order.
- Select Copy to keep both lines.
How a shared exponent is chosen
Ordinary floating point stores an exponent with every number. A shared-exponent or block floating point format stores one exponent for a group of numbers and keeps only an integer mantissa per number. Each value is then mantissa x 2^exponent.
The tool first works out the largest mantissa a signed field of the given width can hold on both sides of zero: 2^(bits - 1) - 1, which is 127 for 8 bits. It finds the largest absolute value in the list and computes exponent = ceil(log2(largest) - log2(max mantissa)). Every value is then divided by 2^exponent and rounded to the nearest integer. A list of zeros gets exponent 0.
Worked example: -13, 0.75 and 3.5 in 8 bits
The largest magnitude is 13. log2(13) is about 3.70 and log2(127) is about 6.99. The difference is -3.29, and rounding up gives an exponent of -3. The step is therefore 2^-3 = 0.125. Dividing gives -104, 6 and 28, and all three values happen to be exact multiples of the step.
Drop to 4 mantissa bits and the limit is 7. The exponent rises to 1, a step of 2. The mantissas become -6, 0 and 2, which reconstruct to -12, 0 and 4. The small value 0.75 is gone.
Values: -13, 0.75, 3.5
Mantissa bits: 8
Shared exponent: -3
Mantissas: -104, 6, 28
Mantissa bits: 4
Shared exponent: 1
Mantissas: -6, 0, 2The cost of sharing: small values lose bits
One exponent has to serve the largest value in the block, so smaller values use only part of the mantissa. Enter 1000000, 5 at 8 bits: the exponent is 13, the mantissas are 122 and 0, and the 5 disappears while the million comes back as 999,424. Formats based on this idea keep blocks small or group values of similar magnitude for that reason.
Where shared exponents are used
The same structure appears under different names in signal processing, graphics and machine learning.
- Fixed-point arithmetic. A shared exponent of -n is a Q format with n fractional bits, so -3 means three bits after the binary point.
- Block floating point in DSP, for example scaling a whole FFT stage or a block of samples by one exponent.
- High dynamic range texture formats that store three color mantissas with one common exponent.
- Compressed tensors and gradients, where an exponent per block is cheaper than one per element.
Input rules and numeric limits
Each value must be a finite decimal number, optionally in scientific notation, and the list may hold at most 100,000 of them. Mantissa bits includes the sign bit. The exponent is never set below -1074. Exact ties round toward positive infinity, so -6.5 becomes -6. The list is processed in your browser.
Frequently asked questions
What is a shared exponent?
It is a single power-of-two scale factor applied to a group of integers. Instead of storing an exponent for every number as IEEE floats do, the group stores one, which saves space and lets the arithmetic run on plain integers.
How do I get the original values back?
Multiply each mantissa by 2 to the power of the shared exponent. With exponent -3, the mantissa 28 gives 28 x 0.125 = 3.5. The result equals the input only if the input was a multiple of the step. Otherwise it is the nearest multiple.
Why did one of my values turn into 0?
Its magnitude is less than half of one step, 2^exponent. The step is set by the largest value in the list, so a wide spread of magnitudes pushes small values below the resolution. Add mantissa bits or split the list into blocks.
Can the shared exponent be positive?
Yes. When the largest value exceeds the mantissa limit, the values must be scaled down, and the exponent is positive. The single value 128 with 8 mantissa bits gives exponent 1 and mantissa 64.