← 返回工具箱 ← Back to Tools

数值 / 格式Numbers / Formats

浮点数位拆解Float Bit Inspector

输入任意数字,看它如何被塞进 8 / 16 / 32 / 64 个格子:符号、指数、尾数各占几位,存进去的到底是谁,误差有多大。 Type any number and see how it lands in 8 / 16 / 32 / 64 cells: how many bits go to sign, exponent, and mantissa — and what actually gets stored.

支持 0.1 / -3.14 / 1e8 / π / infsupports 0.1 / -3.14 / 1e8 / π / inf

输入的数Input
实际存储的数(精确)Actually stored (exact)
绝对误差Absolute error
相对误差Relative error
状态Class
点击行可切换主格式click a row to switch format
格式Format 位分布Bits 存储值(精确)Stored (exact) 绝对误差Abs error

* 整数格式(INT2 / INT4 / INT8):小数会截断取整,超出表示范围会饱和。E4M3 没有无穷大,溢出时饱和到 ±448。 * Integer formats (INT2 / INT4 / INT8): fractions truncate, values beyond range saturate. E4M3 has no infinity — overflow saturates to ±448.

原理速览:定点数 → 浮点数 → FP8 家族 Primer: fixed-point → floating-point → the FP8 family

定点数:小数点不动Fixed-point: the point never moves

8 个格子直接存二进制、约定小数点位置,就是定点数。前 4 位整数、后 4 位小数——范围和精度在编码前就锁死了,二者不可兼得。 Store raw binary and fix the radix point somewhere — that's fixed-point. Four integer bits, four fraction bits: range and precision are frozen at design time, and you can't have both.

浮点数:让小数点浮动Floating-point: let the point float

(−1)s × 1.m × 2e —— 用指数控制小数点位置。调小指数可以逼近 0.000000001,调大指数可以够到十亿。代价是:大数的绝对精度被牺牲了,保住的是相对精度。 (−1)s × 1.m × 2e — the exponent moves the radix point. Small exponents reach 0.000000001; large ones reach billions. The price: absolute precision of huge numbers is traded away, while relative precision survives.

FP8 家族:同一套格子,不同分法The FP8 family: same cells, different splits

E4M3(±448,精度优先)、E5M2(±57344,范围优先)是英伟达 GPU 硬件支持的两种 FP8。UE8M0 干脆砍掉尾数和符号,只留 8 位指数——每个值都是 2 的幂,乘法退化成位移,硬件最好优化,DeepSeek 用它存缩放因子。 E4M3 (±448, precision-first) and E5M2 (±57344, range-first) are the two FP8 formats NVIDIA GPUs implement. UE8M0 drops sign and mantissa entirely — every value is a power of two, multiplication becomes a bit shift, which is why DeepSeek uses it for scaling factors.

为什么一亿不需要绝对精度Why 100 million doesn't need absolute precision

对一亿来说,「一亿」和「一亿点零零零零一」的差别完全可以忽略。两个相邻浮点数的间隔随大小增长,所以既装得下极大的范围,又没损失相对精度——这就是浮点数的既要又要。 At 100 million scale, the difference between 100000000 and 100000000.00001 is negligible. The gap between adjacent floats grows with magnitude, so you get enormous range without losing relative precision — the best of both worlds, at a price you don't feel.