6-bit floating point numbers ============================ uses a 6-bit number to represent fractional values from -14 to +14. there are 64 distinct float6 values. this is not a real specification but the ideas and layout directly translate to other floating point types (float32 and float64, float16 and bfloat16, and so on). BIT LAYOUT: 1 bit sign (0 is positive, 1 is negative) 3 bits exponent (the value's magnitude) 2 bits mantissa (the value's closest interval) BIT PATTERNS: s eee mm value = === == ============================ 1 111 00 -inf, "negative infinity" 0 111 00 +inf, "positive infinity" _ 111 __ NaN, "not a number" (m != 0) _ ___ __ normal number (1 <= e <= 6) 1 000 00 -0, "negative zero" 0 000 00 0, "zero" _ 000 __ subnormal number (m != 0) RANGE: -14 to +14 (-1.75 * 8 to +1.75 * 8) FORMULA FOR NORMAL NUMBERS (1 <= e <= 6): (1 - 2*sign) * (1 + mantissa/4) * 2^(e-3) FORMULA FOR SUBNORMAL NUMBERS (e=0): (1 - 2*sign) * (0 + mantissa/4) * 2^-2 SENTINAL VALUES (special values that aren't numbers): -inf (s=1 e=7 m=0) +inf (s=0 e=7 m=0) NaN (e=7 m!=0) CHART SHOWING ALL 64 VALUES (symbolic) e | s=1,m=3 | s=1,m=2 | s=1,m=1 | s=1,m=0 | s=0,m=0 | s=0,m=1 | s=0,m=2 | s=0,m=3 | =================================================================================== 7 | NaN | NaN | NaN | -inf | +inf | NaN | NaN | NaN | 6 | -1.75*8 | -1.50*8 | -1.25*8 | -1.00*8 | +1.00*8 | +1.25*8 | +1.50*8 | +1.75*8 | 5 | -1.75*4 | -1.50*4 | -1.25*4 | -1.00*4 | +1.00*4 | +1.25*4 | +1.50*4 | +1.75*4 | 4 | -1.75*2 | -1.50*2 | -1.25*2 | -1.00*2 | +1.00*2 | +1.25*2 | +1.50*2 | +1.75*2 | 3 | -1.75*1 | -1.50*1 | -1.25*1 | -1.00*1 | +1.00*1 | +1.25*1 | +1.50*1 | +1.75*1 | 2 | -1.75/2 | -1.50/2 | -1.25/2 | -1.00/2 | +1.00/2 | +1.25/2 | +1.50/2 | +1.75/2 | 1 | -1.75/4 | -1.50/4 | -1.25/4 | -1.00/4 | +1.00/4 | +1.25/4 | +1.50/4 | +1.75/4 | 0 | -0.75/4 | -0.50/4 | -0.25/4 | -0.00/4 | +0.00/4 | +0.25/4 | +0.50/4 | +0.75/4 | CHART SHOWING ALL 64 VALUES (literal) e | s=1,m=3 | s=1,m=2 | s=1,m=1 | s=1,m=0 | s=0,m=0 | s=0,m=1 | s=0,m=2 | s=0,m=3 | =================================================================================== 7 | NaN | NaN | NaN | -inf | +inf | NaN | NaN | NaN | 6 | -14 | -12 | -10 | -8 | 8 | 10 | 12 | 14 | 5 | -7 | -6 | -5 | -4 | 4 | 5 | 6 | 7 | 4 | -3.5 | -3 | -2.5 | -2 | 2 | 2.5 | 3 | 3.5 | 3 | -1.75 | -1.5 | -1.25 | -1 | 1 | 1.25 | 1.5 | 1.75 | 2 | -0.875 | -0.75 | -0.625 | -0.5 | 0.5 | 0.625 | 0.75 | 0.875 | 1 | -0.4375| -0.375 | -0.3125| -0.25 | 0.25 | 0.3125| 0.375 | 0.4375| 0 | -0.1875| -0.125 | -0.0625| -0 | 0 | 0.0625| 0.125 | 0.1875| NOTES: - exact integer values are only available from -8 to +8 - there are the same number of positive and negative values - there are two zero values (zero and negative zero) - negative zero and zero are typically considered equal (except during specific numerical algorithms) - there are six different NaN values - each value actually represents an interval of possible numbers - when doing math with floating point, the "nearest" value is chosen as the result