Number System

In this tutorial, you will learn about number system, why they are used as well as the various representations of number system. Also, you will learn the concept of radix and see in detail some common radix-based number systems like Binary, Octal, Decimal, and Hexadecimal number systems.

Contents:

  1. What is Number System?
  2. Forms of Representations in Number Systems
  3. Radix – R Representation
  4. Binary Number System
  5. Decimal Number System
  6. Octal Number System
  7. Hexadecimal Number System
  8. Counting in All Number Systems

What is Number System?

The number system is the systematic way to represent numbers. It is the basis of all computational work in the world. Once a number system is defined, we can develop arithmetic for it to do calculations.

Some important points related to number systems are:

  • Any number system has a base also known as radix, which gives the number of unique symbols in that system. Radix must be ≥ 2, for any number system.
  • In all number systems, the symbols begin from 0 and go till 9. For radix ≥ 9, we include letters from the English alphabet as symbols in our number system to represent further numbers.
  • The base of a number can be written as a subscript. For example, (23)10 is a number in the base 10 number system.

Forms of Representations in Number Systems

Number Systems have broadly four ways of representation. Different representations are used at different places as per requirement. Each form presents an extended view to look at numbers as well as removes ambiguity in number systems. The following figure shows the categories of its representation.

advertisement
advertisement
categories of Number System Representation

As shown in the above figure, the four ways of representation of number systems are: –

  1. Radix R representation: In this form, we show numbers as a part of different radix-based systems and develop the concepts of counting for them.
  2. BCD Codes: BCD stands for binary coded decimal. This form is mainly to represent all numbers in 0 and 1 form with the positional weights of binary system namely, 8 4 2 1 varied to different values. It aims to code data in terms of positional weights.
  3. Data representation: This is a form exclusively to differentiate between positive and negative numbers. It develops the concept of how to represent negative numbers in any number system.
  4. Fixed and Floating Point Representation: This form is aimed at devising a standard to represent fractional values in number systems with a certain amount of precision.

In this tutorial, we shall be seeing the radix r form of number systems representation

Radix R representation

There are four major radix-based systems in use, namely, the Binary number system, the Octal number system, the Decimal number system, and the Hexadecimal number system. Also, the rules will apply to any new radix-based number system that comes up.

Radix r implies 0 to r-1 symbols for that number system. For example,

  • Decimal number system has base 10: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
  • Binary number system has base 2: 0, 1
  • Octal number system has base 8: 0, 1, 2, 3, 4, 5, 6, 7
  • Hexadecimal number system has base 16: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F

Any number can be expressed in a number system with radix r as shown in the figure:

radix product form of a number

As shown in the figure,

  • The point separating the fractional part and integral part is known as the radix point.
  • For the integer part: For n digits, we multiply the digits with positive powers of the radix, starting from power 0, moving left from digit0 to digitn-1.
  • For fractional part: For n digits, we multiply the digits with negative powers of the radix, starting from power -1, moving right from digit1 to digitn.
  • The leftmost digit of a number is known as Most Significant Bit (MSB) as it has the highest power of radix multiplied with it.
  • The rightmost digit of a whole number is known as Least Significant bit (LSB) as it has the least power of the radix multiplied with it. LSB may change in case it is a fractional number.

Also, numbers from different radix-based number systems are interconvertible. Radix-based number systems are also known as positional numeral systems as each digit contributes to the overall value of the number according to its position in the number.

advertisement

Binary Number System

The binary number system is a base-2 number system. Some important points related to it are as follows:

  • A binary digit is known as a bit.
  • In the binary number system, we have two digits namely 0 and 1. So all binary numbers are sequences of zeros and ones.
  • All codes directly understandable by computers are stored in binary.
  • The radix point is known as the binary point.
  • A group of four bits is known as a nibble.
  • A group of eight bits is known as a byte.
  • Higher units used are kilobytes (KB), megabytes (MB), gigabytes (GB), and terabytes (TB). 1024 bytes make a kilobyte, 1024 kilobytes make a megabyte, and so on.
  • The binary number system was introduced because electronic switches used in hardware usually can have two states: ON or OFF.
  • 0 represents OFF or logic LOW and 1 represents ON or logic HIGH in positive logic. In negative logic, 0 is considered as HIGH and 1 as LOW.

Example: (10101)2 is a binary number.
(10101.10)2 = 1 x 24 + 0 x 23 + 1×22 + 0 x 21 + 1 x 20 + 1 x 2-1 + 0 x 2-2

Decimal Number System

The decimal number system is a base-10 number system. Some points related to it are as follows: –

  • It is the most widely used number system in real life.
  • It has 0-9 characters.
  • The expansion of a number as a product of positional weights and powers of the radix, in any base, always gives the equivalent of the number in the decimal system.
  • The radix point is known as the decimal point.
  • In the decimal system, to represent a negative number in the real world, a minus symbol is put in front of it. In digital systems, 9’s and 10’s complements are used to represent negative decimal numbers.
  • The decimal number system is advantageous as it is easy to use and is friendlier in its arithmetic operations.

Example of decimal number: 5432.10
(5432.10)10 = 5 x 103 + 5 x 102 + 5 x 101 + 5 x 100 + 1 x 10-1 + 0 x 10-2

advertisement

Octal Number System

The octal number system is a base-8 number system. Some points related to it are as follows: –

  • The octal number system has 8 characters ranging from 0 – 7.
  • The radix point is known as the octal point.
  • Three binary bits can represent octal numbers.
  • It has the benefit of not requiring additional symbols over the hexadecimal number system.
  • It is originated with 8 being the base for all computing platforms. For example, we have 8 bits making a byte. Further, we have 16-bit, 32-bit, 64-bit systems all of which are multiples of 8.
  • In computer systems, octal numbers are identified with a prefix of 0o.
  • The octal number system is used in aviation for transmitting codes to ground stations.

Example of an octal number: 721
(721)8 = 7 x 82 + 2 x 81 + 1 x 80

Hexadecimal Number System

The hexadecimal number system is a base-16 number system. Some major points about it are as follows: –

  • Hexadecimal has 16 symbols ranging from 0- F.
  • Hexadecimal is a friendlier form of representing binary as each hexadecimal digit can be shown by four binary bits.
  • The prefix 0x is used in computer systems to identify hex numbers. Alternatively, the letter H can be added at the end.
  • The symbols A-F have equivalent values of 10-15 respectively. While expanding a hexadecimal number, these values are multiplied in place of the symbols.
  • Hexadecimal system usage: Color coding is done in hex, assembly languages use hexadecimal for encoding opcodes, IP addresses use hexadecimal notation. In short, hexadecimal is the most widely used system in programming.

Example of a hexadecimal number: A23 or A23H
(A23)16 = 10 x 162 + 2 x 161 + 3 x 160

Counting in All Number Systems

In any base system, after we exhaust the last most symbol the next counting begins from 10. As 10 on expanding in any base, gives the base number itself. For example,

  • In binary after 1 comes 2, and 2 in binary is represented by 10, as on expanding, 1 x 21 + 0 x 20 = 2
  • In octal after 7 comes 8, and 8 in octal is represented by 10, as on expanding, 1 x 8 1 + 0 x 80 = 8

Generally, every time we hit the end of the character set while counting, we increment the left digit’s value by one and repeat the available character set. For example, in hexadecimal, after F comes 10, 11……..19, 1A, 1B…..1F, after which comes 20….2F…….FF, 100, 101… and so on.

Here is a table that shows counting in each number system from 0 to 16. Notice the 10 in each number system and where it occurs.

BINARY OCTAL DECIMAL HEXADECIMAL
0000 0 0 0
0001 1 1 1
0010 2 2 2
0011 3 3 3
0100 4 4 4
0101 5 5 5
0110 6 6 6
0111 7 7 7
1000 10 8 8
1001 11 9 9
1010 12 10 A
1011 13 11 B
1100 14 12 C
1101 15 13 D
1110 16 14 E
1111 17 15 F
10000 20 16 10

Key Points to Remember

Here is a list of key points to remember about “Number System”.

  • Any number system with radix r has 0 to (r-1) symbols in it. Radix ≥ 2 for any number system.
  • All radix-based number systems are interconvertible.
  • There are four types of number systems representations: – Radix-based, BCD codes, Data, and fixed and floating-point representations.
  • Decimal (base 10 {0-9}), Hexadecimal (base 16 {0-F}), Octal (base 8 {0-7}) and Binary (base 2 {0,1}), are the generally used radix-based number systems.
  • MSB stands for the most significant bit and LSB stands for the least significant bit. MSB is the leftmost bit and LSB is the rightmost bit.
  • In the hexadecimal number system, A-F has values 10-15 respectively.
  • In the hexadecimal number system, A-F has values 10-15 respectively.
  • 10 in any number system is numerically equivalent to the base of that number system.
  • While counting in any number system, on reaching the end of the available character set, we increment the left bit by 1 and repeat 0 to r-1 characters.

If you find any mistake above, kindly email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.