Q# 1: What is a numbers system?
In mathematics, a 'number system' is a set of numbers, together with one or more operations, such as addition or multiplication.
A number system is a way of counting things. It's a way of identifying the quantity of something. Q#2: What is expansion method?
There are a number of ways to convert a number in one base (radix) to the equivalent number in another base. The standard techniques are all variations on three basic methods.
The most straightforward technique is the expansion method. Suppose we wish to convert the binary number 10101.1 to decimal. We may write
10101.12 =1 x 24 + 0 x 23 + 1 x 22 + 0 x 21 + 1 x 20 + 1 x 2-1 = 16 + 0 + 4 + 0 + 1 + 0.5
= 21.510
Q#3: What is decimal number system? Convert from any base to decimal.
Convert from Any Base to Decimal
Let's think more carefully what a decimal number means. For example, 1234 means that there are four boxes (digits); and there are 4 one's in the right-most box (least significant digit), 3 ten's in the next box, 2 hundred's in the next box, and finally 1 thousand's in the left-most box (most significant digit). The total is 1234:
Original Number: 1 2 3 4 | | | | How Many Tokens: 1 2 3 4 Digit/Token Value: 1000 100 10 1 Value: 1000 + 200 + 30 + 4 = 1234
or simply, 1*1000 + 2*100 + 3*10 + 4*1 = 1234
Thus, each digit has a value: 10^0=1 for the least significant digit, increasing to 10^1=10, 10^2=100, 10^3=1000, and so forth.
Q#4: What is positional number system? Positional number systems
Our decimal number system is known as a positional number system, because the value of the number depends on the position of the digits. For example, the number 123 has a very different value than the number 321, although the same digits are used in both numbers.
Converting from other number bases to decimal
Other number systems use different bases. The binary number system uses base 2, so the place values of the digits of a binary number correspond to powers of 2. For example, the value of the binary number10011 is determined by
computing the place value of each of the digits of the number:
1 0 0 1 1 the binary number 2^4 2^3 2^2 2^1 2^0 place values So the binary number 10011 represents the value
(1 * 2^4) + (0 * 2^3) + (0 * 2^2) + (1 * 2^1) + (1 * 2^0)
= 16 + 0 + 0 + 2 + 1
= 19
The same principle applies to any number base. For example, the number 2132 base 5 corresponds to 2 1 3 2 number in base 5
5^3 5^2 5^1 5^0 place values Converting from decimal to other number bases
In order to convert a decimal number into its representation in a different number base, we have to be able to express the number in terms of powers of the other base. For example, if we wish to convert the decimal number 100 to base 4, we must figure out how to express 100 as the sum of powers of 4.
= (1 * 4^3) + (2 * 4^2) + (1 * 4^1) + (0 * 4^0)
Then we use the coefficients of the powers of 4 to form the number as represented in base 4:
100 = 1 2 1 0 base 4
Repeated Division Method:
One way to do this is to repeatedly divide the decimal number by the base in which it is to be converted, until the quotient becomes zero. As the number is divided, the remainders - in reverse order - form the digits of the number in the other base.
Example: Convert the decimal number 82 to base 6:
82/6 = 13 remainder 4
13/6 = 2 remainder 1
2/6 = 0 remainder 2 The answer is formed by taking the remainders in reverse order: 2 1 4 base 6 Q#5: What is Binary number system?
The binary number system works like the decimal number system except the Binary Number System: uses base 2
includes only the digits 0 and 1 Number Base Conversion Binary to Decimal
It is very easy to convert from a binary number to a decimal number. Just like the decimal system, we multiply each digit by its weighted position, and add each of the weighted values together. For example, the binary value 1100 1010
represents:
1*2^7 + 1*2^6 + 0*2^5 + 0*2^4 + 1*2^3 + 0*2^2 + 1*2^1 + 0*2^0 = 1 * 128 + 1 * 64 + 0 * 32 + 0 * 16 + 1 * 8 + 0 * 4 + 1 * 2 + 0 * 1 = 128 + 64 + 0 + 0 + 8 + 0 + 2 + 0 =202
Decimal to Binary
To convert decimal to binary is slightly more difficult. There are two methods, that may be used to convert from decimal to binary.
1. Repeated division by 2,
2. Repeated subtraction by the weighted position value. Repeated Division By 2
For this method, divide the decimal number by 2, if the remainder is 0, on the side write down a 0. If the remainder is 1, write down a 1. This process is continued by dividing the quotient by 2 and dropping the previous remainder until the quotient is 0.
When performing the division, the remainders which will represent the binary equivalent of the decimal number are written beginning at the least significant digit (right) and each new digit is written to more significant digit (the left) of the previous digit. Consider the number 2671.
Octal Number System
The Octal Number Base System
Although this was once a popular number base but it is rarely used today. The Octal system is based on the binary system with a 3-bit boundary. The Octal Number System:
includes only the digits 0 through 7
(any other digit would make the number an invalid octal number) Binary to Octal Conversion
It is easy to convert from an integer binary number to octal. This is accomplished by: Break the binary number into 3-bit sections from the LSB to the MSB.
Convert the 3-bit binary number to its octal equivalent. For example, the binary value 1010111110110010 will be written: 001 010 111 110 110 010
1 2 7 6 6 2
Octal to Binary Conversion
It is also easy to convert from an integer octal number to binary. This is accomplished by: Convert the decimal number to its 3-bit binary equivalent.
Combine the 3-bit sections by removing the spaces. For example, the octal value 127662 will be written:
1 2 7 6 6 2
001 010 111 110 110 010
This yields the binary number 001010111110110010 or 00 1010 1111 1011 0010 in our more readable format. Octal to Decimal Conversion
To convert from Octal to Decimal, multiply the value in each position by its Octal weight and add each value. Using the value from the previous example, 127662, we would expect to obtain the decimal value 44978.
1*8^5 2*8^4 7*8^3 6*8^2 6*8^1 2*8^0 1*32768 2*4096 7*512 6*64 6*8 2*1 32768 8192 3584 384 48 2 32768 + 8192 + 3584 + 384 + 48 + 2 = 44978
Decimal to Octal Conversion
To convert decimal to octal is slightly more difficult. The typical method to convert from decimal to octal is repeated division by 8.
We may also use repeated subtraction by the weighted position value; it is more difficult for large decimal numbers. Repeated Division By 8
For this method, divide the decimal number by 8, and write the remainder on the side as the least significant digit. This process is continued by dividing the quotient by 8 and writing the remainder until the quotient is 0.
When performing the division, the remainders which will represent the octal equivalent of the decimal number are written beginning at the least significant digit (right) and each new digit is written to the next more significant digit (the left) of the previous digit. Consider the number 44978.
Division Quotient Remainder Octal Number
44978 / 8 5622 2 2 5622 / 8 702 6 62 702 / 8 87 6 662 87 / 8 10 7 7662 10 / 8 1 2 27662 1 / 8 0 1 127662
The Hexadecimal Number Base System .
The Hexadecimal system is based on the binary system using a Nibble or 4-bit boundary. The Hexadecimal Number System:
The hexadecimal is base 16 numbering system. Uses base 16
Includes only the digits 0 through 9 and the letters A, B, C, D, E, and F Hexadecimal numbers offer the two features:
Hex numbers are very compact
It is easy to convert from hex to binary and binary to hex
In the Hexadecimal number system, the hex values greater than 9 carry the following decimal value:
10 0AH 11 0BH 12 0CH 13 0DH 14 0EH 15 0FH
This table provides all the information you'll ever need to convert from one number base into any other number base for the decimal values from 0 to 16.
Hexadecimal number into a binary number Conversion:
To convert a hexadecimal number into a binary number, simply break the binary number into 4-bit groups beginning with the LSB and substitute the corresponding four bits in binary for each hexadecimal digit in the number.
For example, to convert 0ABCDh into a binary value, simply convert each hexadecimal digit according to the table above. The binary equivalent is:
0ABCDH = 0000 1010 1011 1100 1101
To convert a binary number into hexadecimal format is almost as easy. The first step is to pad the binary number with leading zeros to make sure that the binary number contains multiples of four bits. For example, given the binary number 10 1100 1010, the first step would be to add two bits in the MSB position so that it contains 12 bits. The revised binary value is 0010 1100 1010. The next step is to separate the binary value into groups of four bits, e.g., 0010 1100 1010. Finally, look up these binary values in the table above and substitute the appropriate hexadecimal digits, e.g., 2CA.
The weighted values for each position is as follows: 16^3 16^2 16^1 16^0
4096 256 16 1
Binary to Hex Conversion:
It is easy to convert from an integer binary number to hex. This is accomplished by: Break the binary number into 4-bit sections from the LSB to the MSB.
Convert the 4-bit binary number to its Hex equivalent.
For example, the binary value 1010111110110010 will be written: 1010 1111 1011 0010
Hex to Binary Conversion:
It is also easy to convert from an integer hex number to binary. This is accomplished by: Convert the Hex number to its 4-bit binary equivalent.
Combine the 4-bit sections by removing the spaces. For example, the hex value 0AFB2 will be written:
A F B 2
1010 1111 1011 0010
This yields the binary number 1010111110110010 or 1010 1111 1011 0010 in our more readable format. Hex to Decimal Conversion:
To convert from Hex to Decimal, multiply the value in each position by its hex weight and add each value. Using the value from the previous example, 0AFB2H, we would expect to obtain the decimal value 44978.
A*16^3 F*16^2 B*16^1 2*16^0 10*4096 15*256 11*16 2*1
40960 3840 176 2
40960 + 3840 + 176 + 2 = 44978 Decimal to Hex Conversion:
To convert decimal to hex is slightly more difficult. The typical method to convert from decimal to hex is repeated division by 16. While we may also use repeated subtraction by the weighted position value, it is more difficult for large decimal numbers. Repeated Division By 16
For this method, divide the decimal number by 16, and write the remainder on the side as the least significant digit. This process is continued by dividing the quotient by 16 and writing the remainder until the quotient is 0. When performing the division, the remainders which will represent the hex equivalent of the decimal number are written beginning at the least significant digit (right) and each new digit is written to the next more significant digit (the left) of the previous digit. Consider the number 44978.
Division Quotient Remainder Hex Number
44978 / 16 2811 2 2
2811 / 16 175 11 B2
175 / 16 10 15 FB2
10 / 16 0 10 0AFB2
As you can see, we are back with the original number. That is what we should expect. Q#6:Define one’s and two’s complement.
One’s complement:
One‟s complement of a binary number is obtained by changing all 0‟s to 1‟s and all 1‟s to 0‟s.
To negate a number, replace all zeros with ones, and ones with zeros - flip the bits. Thus, 12 would be 00001100, and -12 would be 11110011.
Two’s complement:
Two‟s complement of a binary number is obtained by taking one‟s complement and then adding 1 in the result. Calculation of 2's Complement
To calculate the 2's complement of an integer, invert the binary equivalent of the number by changing all of the ones to zeroes and all of the zeroes to ones (also called 1's complement), and then add one.
0001 0001(binary 17) 1110 1111(two's complement -17)
NOT(0001 0001) = 1110 1110 (Invert bits) 1110 1110 + 0000 0001 = 1110 1111 (Add 1)
2's Complement Addition
Two's complement addition follows the same rules as binary addition.
For example,
5 + (-3) = 2 0000 0101 = +5 + 1111 1101 = -3
0000 0010 = +2
2's Complement Subtraction
Two's complement subtraction is the binary addition of the minuend to the 2's complement of the subtrahend (adding a negative number is the same as subtracting a positive one).
For example,
7 - 12 = (-5) 0000 0111 = +7 + 1111 0100 = -12
1111 1011 = -5
2's Complement Multiplication
Two's complement multiplication follows the same rules as binary multiplication.
For example,
(-4) × 4 = (-16) 1111 1100 = -4 × 0000 0100 = +4
2's Complement Division
Two's complement division is repeated 2's complement subtraction. The 2's complement of the divisor is calculated, then added to the dividend. For the next subtraction cycle, the quotient replaces the dividend. This repeats until the quotient is too small for subtraction or is zero, then it becomes the remainder. The final answer is the total of subtraction cycles plus the remainder.
For example,
7 ÷ 3 = 2 remainder 1 0000 0111 = +7 0000 0100 = +4 + 1111 1101 = -3 + 1111 1101 = -3
0000 0100 = +4 0000 0001 = +1 (remainder) Q#7: what are main data types used in different computer applications? Explain. Data types used in computer application:
Almost all programming languages explicitly include the notion of data type, though different languages may use different terminology. Common data types may include:
Integers: In computer science, the term integer is used to refer to a data type which represents some finite subset of the mathematical integers
Booleans: In computer science, the Boolean or logical data type is a data type, having two values (usually denoted true and false), characters: In computer and machine-based telecommunications terminology, a character is a unit of information that roughly corresponds to symbol, such as in an alphabet in the written form of a natural language.
Floating-point numbers: In computing, floating point describes a method of representing real numbers in a way that can support a wide range of values.
Alphanumeric Strings: In computer programming, a string is traditionally a sequence of characters, Q#8: Define codes. What are the types of codes used in computer?
Codes
When numbers, letters or words are represented by a special group of symbols, we say they are being encoded and the group of system is called "Code".
Types of Codes
The codes include Binary code, Binary-coded-decimal code (BCD), and alpha numeric codes. Alphanumeric codes include ASCII and EBCDIC.
ASCII Code
ASCII stands for American Standard Code for Information Interchange. It is a 7-bit code used to handle alphanumeric data. This code allows manufacturers to standardize input/output devices such as keyboard, printers, visual display units etc. An extension of ASCII code uses 8-bits called as ASCII-8 code with an extra 8th-bit as a parity bit to make the total number of 1's either odd or even.
EBCDIC Code
EBCDIC (Extended Binary Coded Decimal Interchange Code) is an extended form of BCD (Binary Coded Decimal), which can represent only 16 characters because it is a 4-bit code. EBCDIC is an 8-bit code, so it can represent 256 different characters. It was developed by IBM and is used in most IBM models and many other computers.
BCD
"In BCD, a digit is usually represented by four bits which, in general, represent the values/digits/characters 0–9. Other bit combinations are sometimes used for a sign or other indications."
Example: 9 in BCD = 1001 8 in BCD = 1000
MCQs: Chapter No.05
1. Data after processing is called
(a).processed data (b).information (c).raw data (d). facts 2. Collection of facts and figures is called
(a) Information (b).facts (c).data (d).raw data 3. Computer processes data in terms of --- numbers
(a).decimal (b).hexadecimal (c).binary (d).octal
4. The data on which different arithmetic operations can be performed is called (a). numeric data (b).alphanumeric data (c)text data (d). decimal data 5. There are two types of numeric data---and---
(a). integer and real (b). Integer and string (c). Integer and char(d). Integer and number 6. Alphanumeric data contains
(a). alphabets,number (b) alphabets,numbers,chars (c).alphabets,numbers, special charecters (d). alphabets, numbers, string 7. House#678 is an example of
(a).numeric data (b). Alphanumeric data (c).alphabetic data (d)special data 8. Set of values used to represent different quantities is called
(a). decimal system (b). number system (c). octal system (d). binary system 9. Decimal number system range from
(a). 9 to 0 (b). 1 to 10 (c).1 to 9 (d). 0 to 9
10. In Hexadecimal number system F contains the value of ---
(a) 8 (b). 16 (c).15 (d).7
11. In Hexadecimal number system A contains the value of --- (b) 8 (b). 16 (c).15 (d).10
12. The hexadecimal number 10 is equal to
(a). 10 (b).100 (c).16 (d). all of above 13. The hexadecimal number 100 is equal to
(a).0001000000 (b).256 (c).400 (d).all of above 14. 2‟s complement of 0101010 is
(a). 1010110 (b).1010101 (c).0000011 (d).none of these 15. 1‟s complement of a negative binary number can be calculated by
(a). reversing the bits in the number
(b). reversing the bits in the number and adding one (c).cannot be calculated (d).both (a) and (b) 16. (011)475321211 is
(a).numeric data (b).alphanumeric data (c).alphabetic data (d).both ()() 17. IBM introduces a new character coding scheme called
18. EBCDIC was developed from existing coding scheme like
(a).ASCII (b).BCD (c).EBCDIC (d).all of these 19. In EBCDIC code --- different characters can be represented
(a).128 (b).256 (c).512 (d).64
20. In world most of the computers use--- coding scheme
(a).ASCII (b).BCD (c).EBCDIC (d).all of these 21. In ASCII code --- different characters can be represented
(a).128 (b).256 (c).512 (d).64
22. ASCII is --- bit coding scheme
(a).4 (b).7 (c).8 (d).16
23. BCD is --- bit coding scheme
(a).4 (b).7 (c).8 (d).16
24. EBCDIC is --- bit coding scheme
(a).4 (b).7 (c).8 (d).16
25. Unicode is --- bit coding scheme
(a).4 (b).7 (c).8 (d).16
26. BCD Stands for---
(a).binary coded digits(b).binary coded decimal (c).bi-coded decimal (d).None of these 27. EBCDIC Stands for---
(a).extensive binary coded decimal interchange code (b). Extended binary coded decimal interchange code (c). Excessive binary coded decimal interchange code (d). Extended binary coded digital interchange code 28. ASCII Stands for---
(a).American standard code for information interchange (b). American standard code for inward interchange (c). Amazon standard code for inward interchange (d). Amazon standard code for information interchange 29. In Unicode--- different characters can be represented
(a).128 (b).256 (c).512 (d).65536 30. 1‟s complement of 1010101 is (a). 0101010 (b).1010100 (c).101001 (d).1010011 Answer Key MCQ’s: 1.b 2.c 3.c 4.a 5.a 6.c 7.b 8.b 9.d 10.c 11.d 12.c 13.c 14.a 15.a 16.b 17.c 18.b 19.b 20.a 21.a 22.b 23.c 24.c 25.d 26.b 27.b 28.a 29.d 30.a