Number Representations & States

"how numbers are stored and used in computers"

FP8

The 8-bit floating point format is a compact numerical representation of real numbers, where each number is represented by a single byte. It is commonly used in machine learning applications where memory usage and bandwidth capabilities are especially important.

Try editing the 8 bit floating point value below.

0
sign
0000
exponent
000
mantissa
=(023)×2(1 - 7)=0×2-7=0

Anatomy of an FP8

Unlike FP32, FP8 is not standardized - while every FP8 format uses 1 bit for the sign, the choice on how the remaining 7 bits should be divided between mantissa and exponent is dependent on the specific FP8 format being used.

Here is an example specification for an FP8 format named E4M3.

e4m3

sign
1 bit
exponent
4 bits
bias
7
mantissa
3 bits

Emin = -6, Emax = 7


sign bit s

given an exponent e

mantissa m

e = 0
m = 0
signed zero
±0
m > 0
subnormal
(-1)s·(
m
8
)·2-6
e > 0
m < 7
normalized value
(-1)s·(1+
m
8
)·2e-7
(-1)s·(1+
m
8
)·2e-7

Since an FP8 can represent 256 possible values, it is easy to visualize their numeric range and distribution with a table.

  E4M3Each row is the first four bits, and each column is the second four bits.

 
0000...
0001...
0010...
0011...
0100...
0101...
0110...
0111...
1000...
1001...
1010...
1011...
1100...
1101...
1110...
1111...
...0000
+0
0.03125
0.125
0.5
2
8
32
128
-0
-0.03125
-0.125
-0.5
-2
-8
-32
-128
...0001
0.001953
0.035156
0.140625
0.5625
2.25
9
36
144
-0.001953
-0.035156
-0.140625
-0.5625
-2.25
-9
-36
-144
...0010
0.003906
0.039063
0.15625
0.625
2.5
10
40
160
-0.003906
-0.039063
-0.15625
-0.625
-2.5
-10
-40
-160
...0011
0.005859
0.042969
0.171875
0.6875
2.75
11
44
176
-0.005859
-0.042969
-0.171875
-0.6875
-2.75
-11
-44
-176
...0100
0.007813
0.046875
0.1875
0.75
3
12
48
192
-0.007813
-0.046875
-0.1875
-0.75
-3
-12
-48
-192
...0101
0.009766
0.050781
0.203125
0.8125
3.25
13
52
208
-0.009766
-0.050781
-0.203125
-0.8125
-3.25
-13
-52
-208
...0110
0.011719
0.054688
0.21875
0.875
3.5
14
56
224
-0.011719
-0.054688
-0.21875
-0.875
-3.5
-14
-56
-224
...0111
0.013672
0.058594
0.234375
0.9375
3.75
15
60
240
-0.013672
-0.058594
-0.234375
-0.9375
-3.75
-15
-60
-240
...1000
0.015625
0.0625
0.25
1
4
16
64
256
-0.015625
-0.0625
-0.25
-1
-4
-16
-64
-256
...1001
0.017578
0.070313
0.28125
1.125
4.5
18
72
288
-0.017578
-0.070313
-0.28125
-1.125
-4.5
-18
-72
-288
...1010
0.019531
0.078125
0.3125
1.25
5
20
80
320
-0.019531
-0.078125
-0.3125
-1.25
-5
-20
-80
-320
...1011
0.021484
0.085938
0.34375
1.375
5.5
22
88
352
-0.021484
-0.085938
-0.34375
-1.375
-5.5
-22
-88
-352
...1100
0.023438
0.09375
0.375
1.5
6
24
96
384
-0.023438
-0.09375
-0.375
-1.5
-6
-24
-96
-384
...1101
0.025391
0.101563
0.40625
1.625
6.5
26
104
416
-0.025391
-0.101563
-0.40625
-1.625
-6.5
-26
-104
-416
...1110
0.027344
0.109375
0.4375
1.75
7
28
112
448
-0.027344
-0.109375
-0.4375
-1.75
-7
-28
-112
-448
...1111
0.029297
0.117188
0.46875
1.875
7.5
30
120
+NaN
-0.029297
-0.117188
-0.46875
-1.875
-7.5
-30
-120
-NaN

Finite and unsigned zeros

There is also a separate specification for an FP8 named E4M3FNUZ, where FN means finite and UZ means unsigned zeros.

  E4M3FNUZEach row is the first four bits, and each column is the second four bits.

 
0000...
0001...
0010...
0011...
0100...
0101...
0110...
0111...
1000...
1001...
1010...
1011...
1100...
1101...
1110...
1111...
...0000
0
0.015625
0.0625
0.25
1
4
16
64
NaN
-0.015625
-0.0625
-0.25
-1
-4
-16
-64
...0001
0.000977
0.017578
0.070313
0.28125
1.125
4.5
18
72
-0.000977
-0.017578
-0.070313
-0.28125
-1.125
-4.5
-18
-72
...0010
0.001953
0.019531
0.078125
0.3125
1.25
5
20
80
-0.001953
-0.019531
-0.078125
-0.3125
-1.25
-5
-20
-80
...0011
0.00293
0.021484
0.085938
0.34375
1.375
5.5
22
88
-0.00293
-0.021484
-0.085938
-0.34375
-1.375
-5.5
-22
-88
...0100
0.003906
0.023438
0.09375
0.375
1.5
6
24
96
-0.003906
-0.023438
-0.09375
-0.375
-1.5
-6
-24
-96
...0101
0.004883
0.025391
0.101563
0.40625
1.625
6.5
26
104
-0.004883
-0.025391
-0.101563
-0.40625
-1.625
-6.5
-26
-104
...0110
0.005859
0.027344
0.109375
0.4375
1.75
7
28
112
-0.005859
-0.027344
-0.109375
-0.4375
-1.75
-7
-28
-112
...0111
0.006836
0.029297
0.117188
0.46875
1.875
7.5
30
120
-0.006836
-0.029297
-0.117188
-0.46875
-1.875
-7.5
-30
-120
...1000
0.007813
0.03125
0.125
0.5
2
8
32
128
-0.007813
-0.03125
-0.125
-0.5
-2
-8
-32
-128
...1001
0.008789
0.035156
0.140625
0.5625
2.25
9
36
144
-0.008789
-0.035156
-0.140625
-0.5625
-2.25
-9
-36
-144
...1010
0.009766
0.039063
0.15625
0.625
2.5
10
40
160
-0.009766
-0.039063
-0.15625
-0.625
-2.5
-10
-40
-160
...1011
0.010742
0.042969
0.171875
0.6875
2.75
11
44
176
-0.010742
-0.042969
-0.171875
-0.6875
-2.75
-11
-44
-176
...1100
0.011719
0.046875
0.1875
0.75
3
12
48
192
-0.011719
-0.046875
-0.1875
-0.75
-3
-12
-48
-192
...1101
0.012695
0.050781
0.203125
0.8125
3.25
13
52
208
-0.012695
-0.050781
-0.203125
-0.8125
-3.25
-13
-52
-208
...1110
0.013672
0.054688
0.21875
0.875
3.5
14
56
224
-0.013672
-0.054688
-0.21875
-0.875
-3.5
-14
-56
-224
...1111
0.014648
0.058594
0.234375
0.9375
3.75
15
60
240
-0.014648
-0.058594
-0.234375
-0.9375
-3.75
-15
-60
-240

  E5M2Each row is the first four bits, and each column is the second four bits.

 
0000...
0001...
0010...
0011...
0100...
0101...
0110...
0111...
1000...
1001...
1010...
1011...
1100...
1101...
1110...
1111...
...0000
+0
0.000488
0.007813
0.125
2
32
512
8192
-0
-0.000488
-0.007813
-0.125
-2
-32
-512
-8192
...0001
0.000015
0.00061
0.009766
0.15625
2.5
40
640
10240
-0.000015
-0.00061
-0.009766
-0.15625
-2.5
-40
-640
-10240
...0010
0.000031
0.000732
0.011719
0.1875
3
48
768
12288
-0.000031
-0.000732
-0.011719
-0.1875
-3
-48
-768
-12288
...0011
0.000046
0.000854
0.013672
0.21875
3.5
56
896
14336
-0.000046
-0.000854
-0.013672
-0.21875
-3.5
-56
-896
-14336
...0100
0.000061
0.000977
0.015625
0.25
4
64
1024
16384
-0.000061
-0.000977
-0.015625
-0.25
-4
-64
-1024
-16384
...0101
0.000076
0.001221
0.019531
0.3125
5
80
1280
20480
-0.000076
-0.001221
-0.019531
-0.3125
-5
-80
-1280
-20480
...0110
0.000092
0.001465
0.023438
0.375
6
96
1536
24576
-0.000092
-0.001465
-0.023438
-0.375
-6
-96
-1536
-24576
...0111
0.000107
0.001709
0.027344
0.4375
7
112
1792
28672
-0.000107
-0.001709
-0.027344
-0.4375
-7
-112
-1792
-28672
...1000
0.000122
0.001953
0.03125
0.5
8
128
2048
32768
-0.000122
-0.001953
-0.03125
-0.5
-8
-128
-2048
-32768
...1001
0.000153
0.002441
0.039063
0.625
10
160
2560
40960
-0.000153
-0.002441
-0.039063
-0.625
-10
-160
-2560
-40960
...1010
0.000183
0.00293
0.046875
0.75
12
192
3072
49152
-0.000183
-0.00293
-0.046875
-0.75
-12
-192
-3072
-49152
...1011
0.000214
0.003418
0.054688
0.875
14
224
3584
57344
-0.000214
-0.003418
-0.054688
-0.875
-14
-224
-3584
-57344
...1100
0.000244
0.003906
0.0625
1
16
256
4096
+Infinity
-0.000244
-0.003906
-0.0625
-1
-16
-256
-4096
-Infinity
...1101
0.000305
0.004883
0.078125
1.25
20
320
5120
+NaN
-0.000305
-0.004883
-0.078125
-1.25
-20
-320
-5120
-NaN
...1110
0.000366
0.005859
0.09375
1.5
24
384
6144
+NaN
-0.000366
-0.005859
-0.09375
-1.5
-24
-384
-6144
-NaN
...1111
0.000427
0.006836
0.109375
1.75
28
448
7168
+NaN
-0.000427
-0.006836
-0.109375
-1.75
-28
-448
-7168
-NaN

  E5M2FNUZEach row is the first four bits, and each column is the second four bits.

 
0000...
0001...
0010...
0011...
0100...
0101...
0110...
0111...
1000...
1001...
1010...
1011...
1100...
1101...
1110...
1111...
...0000
0
0.000244
0.003906
0.0625
1
16
256
4096
NaN
-0.000244
-0.003906
-0.0625
-1
-16
-256
-4096
...0001
0.000008
0.000305
0.004883
0.078125
1.25
20
320
5120
-0.000008
-0.000305
-0.004883
-0.078125
-1.25
-20
-320
-5120
...0010
0.000015
0.000366
0.005859
0.09375
1.5
24
384
6144
-0.000015
-0.000366
-0.005859
-0.09375
-1.5
-24
-384
-6144
...0011
0.000023
0.000427
0.006836
0.109375
1.75
28
448
7168
-0.000023
-0.000427
-0.006836
-0.109375
-1.75
-28
-448
-7168
...0100
0.000031
0.000488
0.007813
0.125
2
32
512
8192
-0.000031
-0.000488
-0.007813
-0.125
-2
-32
-512
-8192
...0101
0.000038
0.00061
0.009766
0.15625
2.5
40
640
10240
-0.000038
-0.00061
-0.009766
-0.15625
-2.5
-40
-640
-10240
...0110
0.000046
0.000732
0.011719
0.1875
3
48
768
12288
-0.000046
-0.000732
-0.011719
-0.1875
-3
-48
-768
-12288
...0111
0.000053
0.000854
0.013672
0.21875
3.5
56
896
14336
-0.000053
-0.000854
-0.013672
-0.21875
-3.5
-56
-896
-14336
...1000
0.000061
0.000977
0.015625
0.25
4
64
1024
16384
-0.000061
-0.000977
-0.015625
-0.25
-4
-64
-1024
-16384
...1001
0.000076
0.001221
0.019531
0.3125
5
80
1280
20480
-0.000076
-0.001221
-0.019531
-0.3125
-5
-80
-1280
-20480
...1010
0.000092
0.001465
0.023438
0.375
6
96
1536
24576
-0.000092
-0.001465
-0.023438
-0.375
-6
-96
-1536
-24576
...1011
0.000107
0.001709
0.027344
0.4375
7
112
1792
28672
-0.000107
-0.001709
-0.027344
-0.4375
-7
-112
-1792
-28672
...1100
0.000122
0.001953
0.03125
0.5
8
128
2048
32768
-0.000122
-0.001953
-0.03125
-0.5
-8
-128
-2048
-32768
...1101
0.000153
0.002441
0.039063
0.625
10
160
2560
40960
-0.000153
-0.002441
-0.039063
-0.625
-10
-160
-2560
-40960
...1110
0.000183
0.00293
0.046875
0.75
12
192
3072
49152
-0.000183
-0.00293
-0.046875
-0.75
-12
-192
-3072
-49152
...1111
0.000214
0.003418
0.054688
0.875
14
224
3584
57344
-0.000214
-0.003418
-0.054688
-0.875
-14
-224
-3584
-57344