i have problem understading floating point representation(two's placement-sign mantissa exponent), check, doing right?
-1/7
-1*1/7*2^0=-1*4/7*2^1=-1*4/7*2^2=-1*8/7*2^3
so in binary itd like:
1 00000011 1.001 001 001 001 001 001 001
1/1357 1*1/1357*2^0=1*2048/1357*2^-11 0 | 11110101 | 1.100 000 100... -205,34 1,60422*2^7 1| 0000011 1 | ...
my main problem when know exponent negative, give me tips?
i assume you're talking float
(i.e. ieee754 binary32)?
in binary, exact value is
-1/7 = -1.001001001001001001001001001…2 × 2−3
firstly, exponent in range [-126,12], don't need worry underflow or overflow.
we round significand 24 bits:
-1.001001001001001001001012 × 2−3
(note last bit of significand rounded up)
we rewrite exponent in it's biased form (the exponent bias 127):
-1.001001001001001001001012 × 2124−127
then can read off bit pattern directly:
1|01111100|00100100100100100100101
where:
- the sign negative, sign bit
1
(1 bit) - 124 in binary
01111100
(8 bits) - we drop implicit leading 1 significand (23 bits)
Comments
Post a Comment