



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!




Algorithm: Assume that: + n is the number of given bits
Decimal number 8-bit two’s complement binary number 16-bit two’s complement binary number 32-bit two’s complement binary number 63 0011 1111 0000 0000 0011 1111 0000 0000 0000 0000 0000 0000 0011 1111
-2,000 Overflow 1111 1000 0011 0000 1111 1111 1111 1111 1111 1000 0011 0000
N = 1111 1111 1111 1111 1111 1111 1110 1001 This is a negative number => We will find its complement: Substract 1 we have: 1111 1111 1111 1111 1111 1111 1110 1000 Invert every bit: 0000 0000 0000 0000 0000 0000 0001 0111 = -N (^) -N = 2 (^4) +2 (^2) +2 (^1) +2 (^0) = 23 (^) N = -
Decimal no. Single precision floating point no Double precision floating point no
n n n n n i i i n n
=> So we have: F = 101010…1010 (52 bits) E = 1022ten = 011 1111 1110 (11 bits) Therefore the presentation is 1 011 1111 1110 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 1010 (0xBFA AAAA AAAA AAAA) 1) Similarly 2) Similarly Notes: N = 1.111 * 10- Since in the single precision, the smallest positive floating number is about (^) N is too small to present (^) underflow ( 1 0. 0 ) 2 (^1 ^127 ) 2 ^126 1. 175494351 10 ^38
a. Bias = 216-1^ -1 = 32767 b.
sample program: #include #include union ieee754_hex{ unsigned int hex; struct{ unsigned int fraction:23; unsigned int exponent:8; unsigned int s:1; } ieee; }; int main(int argc, char *argv[]){ union ieee754_hex hexno;