0% found this document useful (0 votes)
128 views46 pages

Binary Number System: Dr. Odelu Vanga

The document discusses various number systems including binary, floating point, hexadecimal, and octal. It provides examples of converting between decimal, binary, and floating point representations. It also presents some sample questions regarding operations in binary and hexadecimal number systems.

Uploaded by

Divyansh Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
128 views46 pages

Binary Number System: Dr. Odelu Vanga

The document discusses various number systems including binary, floating point, hexadecimal, and octal. It provides examples of converting between decimal, binary, and floating point representations. It also presents some sample questions regarding operations in binary and hexadecimal number systems.

Uploaded by

Divyansh Pandey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 46

Binary Number System

Dr. Odelu Vanga

Department of Computer Science and Information Systems


Birla Institute of Technology and Science Pilani
Hyderabad Campus
[email protected]

January 20, 2019

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 1 / 26


Today’s Topics

Floating Point Data Representation


Convert Decimal Floating to Binary Floating and vis versa
Understand why fixed-point precision required ?

Hexadecimal System
Octal Number System
Binary to Hexadecimal Number (base 16)
Binary to Octal Number (base 8)

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 2 / 26


Interesting Gate Questions

(Gate CS 2002) 4-bit 2’s complement representation of a decimal


number is 1000. Then the number is ———?

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 3 / 26


Interesting Gate Questions

(Gate CS 2002) 4-bit 2’s complement representation of a decimal


number is 1000. Then the number is ———?

(Gate CS 2007) Suppose X = 01110 and Y = 11001 are 5-digit


binary numbers represented in 2’s complement format. The sum
of X and Y in 2’s complement format using 6-bits format is
————-?

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 3 / 26


Interesting Gate Questions

(Gate CS 2002) 4-bit 2’s complement representation of a decimal


number is 1000. Then the number is ———?

(Gate CS 2007) Suppose X = 01110 and Y = 11001 are 5-digit


binary numbers represented in 2’s complement format. The sum
of X and Y in 2’s complement format using 6-bits format is
————-?

(Gate CS 2016) The 16-bit 2’s complement representation of an


integer is 1111 1111 1111 0101. Then it’s decimal representation
is ————?

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 3 / 26


Interesting Gate Questions

(Gate CS 2002) 4-bit 2’s complement representation of a decimal


number is 1000. Then the number is ———?

(Gate CS 2007) Suppose X = 01110 and Y = 11001 are 5-digit


binary numbers represented in 2’s complement format. The sum
of X and Y in 2’s complement format using 6-bits format is
————-?

(Gate CS 2016) The 16-bit 2’s complement representation of an


integer is 1111 1111 1111 0101. Then it’s decimal representation
is ————?

(Gate CS 2005) The rang of integers that can be represented


using n-bit 2’s complement systems: ————?

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 3 / 26


Decimal Equivalent

Decimal point. For example


7 2 3
(284.723)10 = (2×102 +8×101 +4×100 + + 2 + 3 )10
10 10 10

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 4 / 26


Decimal Equivalent

Decimal point. For example


7 2 3
(284.723)10 = (2×102 +8×101 +4×100 + + 2 + 3 )10
10 10 10

Binary point. For example


0 1 1
(1011.011)2 = (1×23 +0×22 +1×21 +1×20 + + 2 + 3 )10
2 2 2

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 4 / 26


Floating Point Conversion

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 5 / 26


Floating Point Conversion

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 6 / 26


Floating Point Conversion

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 7 / 26


Floating Point Conversion

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 8 / 26


Floating Point Conversion

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 9 / 26


Floating Point Conversion

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 10 / 26


Floating Point Conversion

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 11 / 26


Floating Point Conversion

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 12 / 26


Floating Point Conversion

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 13 / 26


Floating Point Conversion

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 14 / 26


Floating Point Data Representation

Decimal to Floating Point Conversion


Convert the absolute value of the decimal number to a binary
integer plus a binary fraction.

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 15 / 26


Floating Point Data Representation

Decimal to Floating Point Conversion


Convert the absolute value of the decimal number to a binary
integer plus a binary fraction.

To convert 4.875 to binary floating point

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 15 / 26


Floating Point Data Representation

Decimal to Floating Point Conversion


Convert the absolute value of the decimal number to a binary
integer plus a binary fraction.

To convert 4.875 to binary floating point


Convert decimal 4 to binary 100.
Convert decimal 0.625 to binary 0.101.
Combine integer and fraction to obtain binary 100.101

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 15 / 26


Floating Point Data Representation

Converting Binary to Decimal


1
0.1 = = 0.510
2

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 16 / 26


Floating Point Data Representation

Converting Binary to Decimal


1
0.1 = = 0.510
2
0 1
0.01 = + 2 = 0.2510
2 2

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 16 / 26


Floating Point Data Representation

Converting Binary to Decimal


1
0.1 = = 0.510
2
0 1
0.01 = + 2 = 0.2510
2 2
0 0 1
0.001 = + + 3 = 0.12510
2 22 2

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 16 / 26


Floating Point Data Representation

Converting Binary to Decimal


1
0.1 = = 0.510
2
0 1
0.01 = + 2 = 0.2510
2 2
0 0 1
0.001 = + + 3 = 0.12510
2 22 2

Convert floating point number 100.101 to decimal number

1 0 1
100.101 = 1 × 22 + 0 × 21 + 0 × 20 + + + 3
2 22 2
= 4 + 0 + 0 + 0.5 + 0 + 0.125

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 16 / 26


Floating Point Data Representation

Converting Binary to Decimal


1
0.1 = = 0.510
2
0 1
0.01 = + 2 = 0.2510
2 2
0 0 1
0.001 = + + 3 = 0.12510
2 22 2

Convert floating point number 100.101 to decimal number

1 0 1
100.101 = 1 × 22 + 0 × 21 + 0 × 20 + + + 3
2 22 2
= 4 + 0 + 0 + 0.5 + 0 + 0.125
= 4.62510

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 16 / 26


Binary-Octal-Hexadecimal

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 17 / 26


Hexadecimal Number System (base-16)

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 18 / 26


Hexadecimal Number System (base-16)

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 19 / 26


Hexadecimal Number System (base-16)

Converting Decimal to Hexadecimal:

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 20 / 26


Hexadecimal Number System (base-16)

Converting Decimal to Hexadecimal:

We denote Hexadecimal number with prefix 0x.


In the above case, the hexadecimal number is 0x103C.

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 20 / 26


Hexadecimal Number System (base-16)

Converting Binary to Hexadecimal


Since 24 = 16, each Hex digit effectively represents the same
numeric count as four binary digits.

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 21 / 26


Hexadecimal Number System (base-16)

Converting Binary to Hexadecimal


Since 24 = 16, each Hex digit effectively represents the same
numeric count as four binary digits.
Another way to say this is that one column in a Hex number is the
same as four columns of a binary number.

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 21 / 26


Hexadecimal Number System (base-16)

Converting Binary to Hexadecimal


Since 24 = 16, each Hex digit effectively represents the same
numeric count as four binary digits.
Another way to say this is that one column in a Hex number is the
same as four columns of a binary number.

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 21 / 26


Hexadecimal Number System (base-16)

Converting Binary to Hexadecimal


Since 24 = 16, each Hex digit effectively represents the same
numeric count as four binary digits.
Another way to say this is that one column in a Hex number is the
same as four columns of a binary number.

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 22 / 26


Hexadecimal Number System (base-16)

Grouping and finding hexadecimal number

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 23 / 26


Hexadecimal Number System (base-16)

Grouping and finding hexadecimal number

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 23 / 26


Octal Number System (base-8)

Convert 5071 into Octal Number System, and then Binary Format.

Decimal to Octal

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 24 / 26


Octal Number System (base-8)

Convert 5071 into Octal Number System, and then Binary Format.

Decimal to Octal Octal to Binary

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 24 / 26


Octal Number System (base-8)

Convert 5071 into Octal Number System, and then Binary Format.

Decimal to Octal Octal to Binary

Octal Number represents


with zero prefix
In the above example, octal
number is “011717”

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 24 / 26


Interesting Questions

2’s compliment representation of a 16-bit number (one sign bit and


15 magnitude bits ) is FFFF. It’s magnitude in decimal
representation is ———–?

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 25 / 26


Interesting Questions

2’s compliment representation of a 16-bit number (one sign bit and


15 magnitude bits ) is FFFF. It’s magnitude in decimal
representation is ———–?

If 73x (in base-x number system) is equal to 54y (in base-y


number system), the possible values of x and y are ————–?

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 25 / 26


Interesting Questions

2’s compliment representation of a 16-bit number (one sign bit and


15 magnitude bits ) is FFFF. It’s magnitude in decimal
representation is ———–?

If 73x (in base-x number system) is equal to 54y (in base-y


number system), the possible values of x and y are ————–?
(A) 8, 16; (B) 10, 12; (C) 9, 13 ; (D) 8, 11

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 25 / 26


Interesting Questions

2’s compliment representation of a 16-bit number (one sign bit and


15 magnitude bits ) is FFFF. It’s magnitude in decimal
representation is ———–?

If 73x (in base-x number system) is equal to 54y (in base-y


number system), the possible values of x and y are ————–?
(A) 8, 16; (B) 10, 12; (C) 9, 13 ; (D) 8, 11

(1217)8 is equivalent to ———- ?


(A) (1217)16 ; (B) (028F )16 ; (C) (2297)10 ; (D) (0B17)16

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 25 / 26


Interesting Questions

2’s compliment representation of a 16-bit number (one sign bit and


15 magnitude bits ) is FFFF. It’s magnitude in decimal
representation is ———–?

If 73x (in base-x number system) is equal to 54y (in base-y


number system), the possible values of x and y are ————–?
(A) 8, 16; (B) 10, 12; (C) 9, 13 ; (D) 8, 11

(1217)8 is equivalent to ———- ?


(A) (1217)16 ; (B) (028F )16 ; (C) (2297)10 ; (D) (0B17)16

P is a 16-bit signed integer. The 2’s complement representation of


P is (F 87B)16 . The 2’s complement representation of 8 × P is
———?

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 25 / 26


.

Thank you

Dr. Odelu Vanga (BITS-Pilani Hyderabad) CS F111 January 20, 2019 26 / 26

You might also like