Sei sulla pagina 1di 13

Number systems

Fixed point Numbers


With paper-and-pencil arithmetic you can use as many digits or bits as are needed. But
computers (usually) use a fixed number of bits for a particular data type. For example, MIPS
(Microprocessor without Interlocked Pipeline Stages) integers are 32 bits. Can a fixed number
of bits be used to express fractions?
Yes. Let us look briefly at an older method, not much used anymore. In the past, some
electronic calculators and some computers used fixed point notation for expressing a
fractional number. With fixed point notation, a number is expressed using a certain number of
bits and the binary point is assumed to be permanently fixed at a certain position.
For example, let us say that fixed point numbers use eight bits and that the binary point is fixed
between the middle two bits, like in the table. (In actual practice, the number of bits would be
much more than eight.) Now to interpret an eight-bit expression, just copy the bits to the table.

Floating Point Numbers


The term floating point is derived from the fact that there is no fixed number of digits before
and after the decimal point; that is, the decimal point can float. There are also representations
in which the number of digits before and after the decimal point is set, called fixed-point
representations. In general, floating-point representations are slower and less accurate than
fixed-point representations, but they can handle a larger range of numbers.
Note that most floating-point numbers a computer can represent are just approximations. One
of the challenges in programming with floating-point values is ensuring that the
approximations lead to reasonable results. If the programmer is not careful, small
discrepancies in the approximations can snowball to the point where the final results become
meaningless.
Because mathematics with floating-point numbers requires a great deal of computing power,
many microprocessors come with a chip, called a floating point unit (FPU ), specialized for
performing floating-point arithmetic. FPUs are also called math coprocessors and numeric
coprocessors.

We can write floating point numbers like below


are
a – mantissa
r – radix
e – exponent

Number 7895 4621 25 789


a 7.895
r 10
e 3

1
Prepared by Mrs. Wimali Perera
Addition of floating point numbers
First you have to arrange the numbers into same exponent and then add them.
245.67 + 4584
2.4567 x 10 2 +
45.8400 x 102
__________________________

48. 2967 x 102


============

1. 5362 + 234.78
2. 1456.3 + 567.56
3. 36789 + 231.678
4. 89 + 456.89

Binary addition

2
Prepared by Mrs. Wimali Perera
Binary Subtraction

3
Prepared by Mrs. Wimali Perera
Binary Multiplication

Binary Division

Octal Addition

4
Prepared by Mrs. Wimali Perera
Octal Subtraction

5
Prepared by Mrs. Wimali Perera
Hexadecimal Addition

6
Prepared by Mrs. Wimali Perera
Hexadecimal Subtraction

Decimal and Binary Fractions

Weigh
22 21 20 . 2-1 2-2 2-3 2-4
t
Place
4 2 1 . 0.5 0.25 0.125 0.0625
Value
Convert the following decimal fractions into binary fractions.

1. 0.5 7. 15.1875
2. 0.125 8. 35.875
3. 4.25 9. 75.2
4. 8.3125 10. 0.350
5. 17.9375 11. 12.575
6. 72.375 12. 25.135

7
Prepared by Mrs. Wimali Perera
Convert the following binary fractions into decimal fractions.

1. 11010.1 5. 100111.111 9. 1001.110


2. 1010.11 6. 101.1001 10. 111000.0011
3. 0.00111 7. 10101.100 11. 11101.011
4. 101101.101 8. 111011.1101 12. 111.1111

Write the 8 bit One’s complement of the following decimal numbers

1. 37 3. -100 5. -48
2. -65 4. 84 6. -15

Solve the following calculations using 8 bit two’s complement arithmetic.

1. 45 + 25 5. 8 + (-60) 9. 40 + (-30)
2. 45 + (-25) 6. 40 + (-50) 10. (-125) + 130
3. 25 + (-45) 7. (-50) + 30
4. 56 + (-53) 8. (-65) + (-8)

Write the 8 bit Two’s complement of the following decimal numbers

1. -

2. 37 6. -48 9. -64
3. -65 7. -15 10. -79
4. -100 8. -125 11. -460
5. -84

Bitwise Operators
1. Bitwise AND (&) Operator

8
Prepared by Mrs. Wimali Perera
2. Bitwise OR ( | ) Operator

3. Bitwise NOT (~) Operator

9
Prepared by Mrs. Wimali Perera
3.

3. Bitwise XOR ( ^ ) Exclusive OR Operator

4. Bitwise Right Shift ( >> ) Operator

10
Prepared by Mrs. Wimali Perera
5. Bitwise Left Shift ( << ) Operator

Revision
2011 AL
1. The binary equivalent to decimal 27 is…..
(1) 000111 (2) 111000 (3) 011011 (4) 101011 (5) 111010

2. C1A16 + 4A216 = ?
(2) 523 (2) FBC (3) FBB (4) 0BC (5) 10BC

3. Show how the computation of 5 + (-3) is done in 8 bit two’s complement arithmetic. Explain
how you deal with the carry bit generated from the most significant bit.

2012 AL
4. The binary equivalent of decimal 37 is?
(1) 0100101 (2) 0100111 (3) 0100100
(4) 0110110 (5) 0110111

5. 1448 + 1758 = ?
(1) 225 (2) 341 (3) 441 (4) 531 (5)314

6. Show how the computation of 15 + (-5) is done in 8 bit two’s complement arithmetic.
Explain how you deal with the carry bit generated from the most significant bit.

2013 AL
7. The binary equivalent of decimal 25 is…
(1) 0100101 (2) 0100111 (3) 0011001
(4) 00101110 (5) 0010111

8. 1248 +1658 = ?
(1) 2048 (2) 28910 (3) 2898 (4) 3118 (5) 3898

9. What is the tow’s complement of -6?


(1) 11111010 (2) 00000110 (3) 111110011

11
Prepared by Mrs. Wimali Perera
(4) 01011111 (5) 00000101

10. Convert 1310 and -1910 into two’s complement arithmetic. Use 8 bit
representation.
11. Compute 1310 – 1910 by using two’s complement numbers obtained in above and
give the answer in twos complement form.
12. Explain how the positive and negative numbers in two’s complement can be converted to
decimal numbers.

2014 AL
13. The decimal number equivalent to the binary 100111 is…
(1) 40 (2) 39 (3)42 (4) 37 (5)36

14. 4A616 + 9910 = ?


(1) 61516 (2) 61510 (3) 50910 (4) 50916 (5) 65916

2015 AL

15. 48B16 + 001010112 + ?


(1) 4B616 (2) 31016 (3) 50316
(4) 51316 (5) 55916

16. Assume that in a particular digital device integers are represented in 8 bit two’s
complement form. However the results of computations are printed in decimal.
(1) Give the representation of 1010 in the above device.
(2) Give the representation of -2510 in the above device.
(3) Explain how the computation of 1010 -2510 done by the device by using your
representations given in sections (1) and (2) above.
(4) List the steps necessary to transform the results obtained in (3) above into decimal form
in order to print the answer.

2016 AL

17. Which of the following binary numbers is equivalent to 10910?


(1) 1100100 (2) 1101101 (3) 1001101
(4) 1101001 (5) 1101100

2017 AL
18. 10116 + 1108 = ?
(1) 42910 (2) 101110 (3) 32910
(4) 52910 (5) 13710

19. What is the two’s complement representation of 45, if an integer is represented by bits?
(1) 11010011 (2) 10110011 (3) 11001101
(4) 00101111 (5) 00101101

20. Which of the following numbers is equivalent to the binary number 101111?
(1) 578 (2) 5716 (3) 5710
(4) 5916 (5) 5F16

12
Prepared by Mrs. Wimali Perera
21. 5D16 + 101112 = ?
(1) 738 (2) 7516 (3) 1168
(4) 1638 (5) 1648

13
Prepared by Mrs. Wimali Perera

Potrebbero piacerti anche