biased rounding 跟 un-biased rounding:
可以参考下面这个例子 :只有-1.5的case有差别。
| S4.4 | S4.0 biased | S4.0 unbiased |
-1 | 111110000 | 11111 | 11111 |
-1.25 | 111101100 | 11111 | 11111 |
-1.5 | 111101000 | 11111 (-1) | 11110 (-2) |
-1.75 | 111100100 | 11110 | 11110 |
-2 | 111100000 | 11110 | 11110 |
signed numbers addition overflow process:
eg. s2.0 + s2.0 = s3.0 to avoid overflow
[-4] | 1 0 0
+ [-1] | 1 1 1
= [-5] | 1 0 1 1
=====================================background knowledge=======================
signed number overflow:
a[N-1:0]. only bit[N-1] and bit[N-2] both have carry, then result does NOT overflow; otherwise, viseverse.
OF = Cn-1 xor Cn-2
eg.1
[+2]cplmnt = 010
[+3]cplmnt = 011
=[-3]cplment=101 (OF=0 xor 1=1, overflow)
eg.2
[-2] = 110
[-3] = 101
=[+3]= 011 (OF=1 xor 0=1, overflow)