Digital Representation 

Representing Sound

The sounds we hear need to be converted into binary for the computer to understand and process it. And the computer handles this by recording the sound and converting it into a digital signal. The samples can then be converted to binary signals and recorded to the nearest whole number.




Number System

A number system is important from the viewpoint of understanding how data are represented before they can be processed by any digital system including a digital computer. And they use a binary number system and are made from binary digital components known as transistors operating in two states (On and Off). The most natural way to represent a number in a computer system is by a string of bits, called a binary number.

In computing, we also use hexadecimal(base 16) or octal (base 8) number systems as a compact form of representing binary numbers.

1. Decimal (Base 10) Number System

The decimal number system consists of 10 digits 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 and is the most commonly used number system. We use the combination of these 10 digits to form all other numbers. The place value table for the decimal number system is as:

2. Binary (Base 2) Number System

In the binary number system, we only use two digits 0 and 1. It means a 2-number system. A binary digit is called a bit and eight bits make a byte.



3. Octal (Base 8) Number System

The octal numeral system is the base-8 number system and uses the digits 0 to 7. That means there are only 8 symbols or digits (0, 1, 2, 3, 4, 5, 6, 7) used to form other numbers.

The main advantage of using the octal number system is that it uses fewer digits than the decimal and hexadecimal number systems. 





3. Hexadecimal (Base 16) Number System

The word hexadecimal comes from Hexa meaning 6, and decimal meaning 10. So, in a hexadecimal number system, there are 16 digits. It consists of digits 0 to 9 and then has the first 5 letters of the alphabet as:


We denote a hexadecimal number with a suffix H or as Hex in short. Most programming languages accept lowercase 'a' to 'f' and uppercase 'A' to 'F'.

Conversion: Decimal to Binary

Conversion steps:
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.



Conversion: Binary to Decimal

Conversion steps:
1. Write the binary number and count the powers of 2 from right to left(starting from 0).

2. Write each binary digit(right to left) with corresponding powers of 2 from right to left, such that the Most Significant Bit(MSB) or the first binary digit will be multiplied by the greatest power of 2.

3. Add all the products in the step2

4. The answer is our decimal number.

Conversion: Binary to Octal

Conversion Step:
1. First, recognize if the number is binary or not. The numbers 0 and 1 with the base 2 are binary numbers.

2. Group all the 0 and 1 in the binary numbers in a set of three starting from the right side (Least Significant Bit: LSB).

3. Add 0’s to the left (Most Significant Bit: MSB) if it doesn’t form a group of three. Make sure each group must have three numbers.

4. Now write the octal equivalent number for each group; the result is the number in the octal number system.


Conversion: Binary to Hexadecimal

Conversion Step:
1. First, recognize if the number is binary or not. The numbers 0 and 1 with the base 2 are binary numbers.

2. Group all the 0 and 1 in the binary numbers in a set of four starting from the right side (Least Significant Bit: LSB).

3. Add 0’s to the left (Most Significant Bit: MSB) if it doesn’t form a group of four. Make sure each group must have four numbers.

4. Now write the Hexadecimal equivalent number for each group and the result is the number in the Hexadecimal number system.

Number Representation

What are numbers in data representation?
Numeric data consists of numbers that can be used in arithmetic operations. Digital devices represent numeric data using the binary number system called base 2.

There are various types of number representation techniques for digital number representation, for example, Binary number systems, octal number systems, decimal number systems, and hexadecimal number system 

Unsigned

Unsigned numbers don't have any sign, these can contain only the magnitude of the number. So, the representation of unsigned binary numbers is all positive numbers only.

Signed

In computing, signed number representations are required to encode negative numbers in binary number systems.

  • Sign and Magnitude: The representation of a signed binary number is commonly referred to as the sign-magnitude notation and if the sign bit is “0”, the number is positive. If the sign bit is “1”, then the number is negative.
  • 1's Complement: A ones' complement system or ones' complement arithmetic is a system in which negative numbers are represented by the inverse of the binary representations of their corresponding positive numbers.
  • 2's Complement: A 2's Complement can be obtained by forming a bit complement of that number, then adding 1.

Addition

Binary addition is much like your normal everyday addition (decimal addition), except that it carries on a value of 2 instead of a value of 10.

The Five rules of binary addition are:

1. 0 + 0 = 0
2. 0 + 1 = 1
3. 1 + 0 = 1
4. 1 + 1 =10
5. 1+ 1+ 1=11

Subtraction

Binary subtraction is similar to decimal subtraction with one difference being that when 1 is subtracted from 0, 1 has to be borrowed from the next higher-order bit, and that bit is reduced by 1.

The Four rules of binary subtraction are:

1. 0 – 0 = 0
2. 0 – 1 = 1 ( with a borrow of 1)
3. 1 – 0 = 1
4. 1 – 1 = 0

From the 2's Complement of the subtrahend(the bottom value) and then perform normal addition. This operation is done in exactly the same manner for both positive and negative numbers.

Overflow

Overflow occurs when there are insufficient bits in a binary number representation to show the result of an arithmetic operation.

Overflow in addition

Addition is said to overflow if the result is too big to fit in the available digits. A 4-bit number, for example, has the range [0, 15]. 4-bit binary addition overflows if the result exceeds 15. The fifth bit of the sum is discarded, producing an incorrect result in the remaining four bits.



Overflow never occurs when adding operands with different signs
Overflow occurs if:
(+A)+(+B)=-C
(-A)+(-B)=+C

Overflow in subtraction

If 2 Two's Complement numbers are subtracted, and their signs are different, then overflow occurs if and only if the result has the same sign as the subtrahend (What is being subtracted).

  1 0 1
- 0 1 1
  -----
  0 1 0
0b010 is 2 which is not the correct result we expected being -6. 




Sign Extention

Sign extension is the operation, in computer arithmetic, of increasing the number of bits of a binary number while saving the number's sign (positive/negative) and value.

For example, if six bits are used to represent the number " 00 1010 " (decimal positive 10) and the sign extends operation increases the word length to 16 bits, then the new representation is simply " 0000 0000 0000 1010 ". Thus, both the value and the fact that the value was positive are maintained.

ThankYou