Posts

Showing posts from August, 2024

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 -> 110