How do I convert 1/3 to signed float 8 bit?
Your notation is pretty standard. The sign bit is obvious to anyone, so I won't address that further. The mantissa is in hidden-bit notation (the "1." is assumed, except in the unique case of an exact zero, which you didn't discuss.) The exponent is in the usual "excess" notation (some bias is added, so that a stored/packed exponent of zero represents the smallest allowable exponent.)



Start with the number you have as \$v\$ (this is a real number, not necessarily an integer) and the number of mantissa bits available as \$m=4\$ and the number of exponent bits available as \$e=3\$. Assuming that \$v\ne 0\$, apply the following logic:


set up a new variable as \$p=0\$.
if \$v\$ is positive, set new variable \$s=0\$ otherwise set \$s=1\$, set \$v=\:\mid v \:\mid\$.
while \$v\lt 2^m\$, set \$p=p-1\$ and \$v=2\cdot v\$.
while \$v\ge 2^{m+1}\$, set \$p=p+1\$ and \$v=\frac{v}{2}\$.
set up a new variable as \$f=\lfloor v\rfloor\$.
if \$\left(v-f\right)\ge \frac{1}{2}\$ set \$f=f + 1\$.
if \$f = 2^{m+1}\$ then set \$p=p+1\$, \$f=\frac{f}2\$.
set up a new variable as \$x=p+m+2^{e-1}-1\$.
if \$x\lt 0\$ or \$x\ge 2^e\$ then error.
it must be that \$2^m\le f\lt 2^{m+1}\$, so set \$f=f-2^m\$.


At this point, you find the result as \$\left&lt;[\;s\;]_1\quad[\;f\;]_m\quad[\;x\;]_e\right&gt;\$, with the subscripts indicating the number of bits for each field. (If \$v=0\$ then the entire result has all bits as zero.)

(Note that I've buried the exponent's excess value in the algorithm because it is almost always handled this way.)



Steps 1 and 2 handle the sign bit and prepare for the remaining steps; steps 3 and 4 perform value normalization; steps 5 and 6 handle value rounding; step 7 deals with the rare case where the rounding required a re-normalization step; step 8 computes the excess exponent notation and step 9 validates that result; and finally step 10 removes the hidden bit from the mantissa prior to packing the floating point notation word.



I just dashed this off quickly and I'll gladly correct any uncovered algorithm errors.