Number Systems

Kavindya Gnanathilake
4 min readJun 29, 2023

--

Introduction to number systems.

A way of writing numbers is known as a number system. Computers use machine language to communicate with each other. The positional number system, in which the value of each digit varies based on where it appears in the number, is understandable to computers.

sub-types of number systems

Decimal number systems.

We frequently utilize the base-10 decimal number system, which includes ten digits from 0 to 9. The units, tens, hundreds, and thousands are represented by the successive places to the left of the decimal point. 4 digits make up the units position of the decimal number 1234, 3 digits make up the tens position, 2 digits make up the hundreds position, and 1 digit makes up the thousands position.

Binary number system.

The simplest method for changing instructions using electric signals is the two-state scheme. While 0 is technically a lower voltage signal, on is displayed as 1 and off as 0, respectively. There are just two digits in the binary number system: 0 and 1. Each digit in the binary number system has a value expressed in powers of 2, making it a positional value system.

Octal number system.

With eight digits (0, 1, 2, 3, 4, 5, 6, and 7), the octal number system is a positional value system. Each digit’s value is represented by a power of 8.

Hexadecimal numbers.

The 16 symbols that make up the octal number system are 0 to 9, A to F, where A is equivalent to 10, B is equal to 11, and so on until F. A positional value system, the hexadecimal number system expresses each digit’s value in powers of 16.

Conversion between number systems.

Decimal-Binary

How to convert?

  1. Divide the number by 2.

2. Get the integer quotient for the next iteration.

3. Get the remainder for the binary digit.

4. Repeat the steps until the quotient is equal to 0.

Examples:

Decimal-Octal

How to convert?

1. Divide the number by 8.

2. Get the integer quotient for the next iteration.

3. Get the remainder for the octal digit.

4. Repeat the steps until the quotient is equal to 0.

Examples:

Decimal-Hexadecimal

How to convert?

1. Divide the number by 16.

2. Get the integer quotient for the next iteration.

3. Get the remainder for the hex digit.

4. Repeat the steps until the quotient is equal to 0.

Examples:

Binary-Hexadecimal

How to convert?

Convert each of the four binary digits to one hex digit:

(We can use the below table for that)

Binary

Hex

0000

0

0001

1

0010

2

0011

3

0100

4

0101

5

0110

6

0111

7

1000

8

1001

9

1010

A

1011

B

1100

C

1101

D

1110

E

1111

F

1000

8

Examples:

Signed numbers representation.

Negative numbers are prefixed with a minus sign in mathematics, whereas negative values are encoded using signed number representations in binary number systems.

Signed & Magnitude representation.

When a number is negative, Sign and Magnitude changes the most significant bit (MSB) to a 1 and subtracts one.

Example:

One’s Complement.

When bitwise NOT is applied to negative binary values, they can be represented using the ones’ complement system.

Example:

Two’s Complement.

Negatives can be stored using 2’s Complement, which is more difficult. There are four actions to take:

1. We must not be using the leftmost, most significant bit for our number. If so, you’ll need to express it with another bit.

2. Find the positive binary number.

3. Swap the 1s for 0s and the 0s for 1s.

4. Add 1.

Example:

--

--

Kavindya Gnanathilake

Data Science Undergraduate at Sri Lanka Institute of Information Technology and Physical Science Undergraduate at Eastern University Sri Lanka