Binary representation of numbers
Binary representation of numbers
In this we will learn how to represent a number in Binary format, Octa, Hex formats
1 - 0001 6 - 0110 11 - 1011 (B)
2 - 0010 7 - 0111 12 - 1100 (C)
3 - 0011 8 - 1000 13 - 1101 (D)
4 - 0100 9 - 1001 14 - 1110 (E)
5 - 0101 10 - 1010 (A) 15 - 1111 (F)
Ex 1: Represent 56 in binary format
56 - (2^5) * 1 + (2^4) * 1 + (2^3) * 1 + (2^2) * 0 + (2^1) * 0 + (2^0) * 0
- (111000)
Ex 2: Represent -56 in binary format
There are multiple ways to represent negative numbers in binary format
1) With sign magnitude, Generally
sign bit - 1 -> Negative numbers
sign bit - 0 -> Positive numbers
3 - 00000011
-3 - 10000011
2) Using 2's complement
-47 -> 1) binary representation of Positive 47 - 101111
2) pad the bits based on format -> 00101111
3) Invert the bits -> 11010000
4) Add 1 to LSB -> 11010001
Ex3: Addition of two negative numbers
-47 -> 11010001
-112 -> 10010000
-----------------
101100001 -> -159 -> Overflow
In this case we need to saturate the value because with 8 bits we can store from -128 to +127 beyond that we saturate the values
IEEE 754 representation of numbers
IEEE -754 is technical standards used to represent floating point numbers. IEEE(Institute of Electrical & Electronic) engineers found hard to identify the floating point they used IEEE format. It is still exiting in most of intel, Mac PCs
It has 3 components
1 8 23 127 - Single Precision Floating point
1 11 52 1023 - Double Precision Floating Point
Ex:1
85.125
85 = 1010101
0.125 = 001
85.125 = 1010101.001
=1.010101001 x 2^6
1. Single precision:
biased exponent 127+6=133
133 = 10000101
Normalised mantisa = 010101001 we will add 0's to complete the 23 bits
The IEEE 754 Single precision is:
= 0 10000101 01010100100000000000000
This can be written in hexadecimal form 42AA4000
2. Double precision:
biased exponent 1023+6=1029
1029 = 10000000101
Normalised mantisa = 010101001
we will add 0's to complete the 52 bits
The IEEE 754 Double precision is:
= 0 10000000101 0101010010000000000000000000000000000000000000000000
This can be written in hexadecimal form 4055480000000000
Comments
Post a Comment