{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

14 Number Representation

# 14 Number Representation - 14 Computer Representation of...

This preview shows pages 1–3. Sign up to view the full content.

Numbers -1 14 - Computer Representation of Integer and Real Numbers In everyday life, numbers are almost exclusively represented using the base 10 decimal system. This means, for example, that an integer N written as N = a n a n —1 a 1 a 0 (N=231) Corresponds to a short-hand for N = ( a n a n —1 a 1 a 0 ) 10 = a n 10 n + a n —1 10 n —1 + … + a 1 10 1 + a 0 10 0 (N= 2 10 3 + 3 10 1 + 1 10 0 ) In the above case, 10 is called the base (or radix ) of the system. The a ’s are integers between 0 and 9. Rational numbers, numbers with decimal points, make use of the negative powers of the base: N = (0. a 1 a 2 a n-1 a n ) 10 = a 1 10 -1 + a 2 10 -2 + … + a n-1 10 -n+1 + a n 10 -n (N= 0.231=2 10 -1 + 3 10 -2 + 1 10 -3 Computers generally use base 2 which is called the binary system . An integer N is represented as N = ( a n a n —1 a 1 a 0 ) 2 = a n 2 n + a n —1 2 n —1 + … + a 1 2 1 + a 0 2 0 (N=11100111) N = 1*2 7 +1∗ 2 6 + 1 2 5 + 0*2 4 + 0 2 3 + 1 2 2 + 1 2 1 + 1 2 0 The a ’s are only allowed to be 0 and 1. The binary system is quite convenient to computers, since the basic unit of information that they store is an electrical pulse which can be either "on" or "off". A single binary digit (a 0 or a 1) is called a bit . An 8-bit sequence of 0’s and 1’s is usually called a byte . MATLAB makes it easy to convert between base 10 (normal) and binary numbers. >> A=dec2bin(231) A =

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Numbers -2 11100111 You can convert the other way using bin2dec . Experiment with this command to figure out how to use it. Storage of binary numbers The set of all integers is countably infinite. This means that in order to represent all integers, computers would need infinite storage capacity. In reality, computers can store only a finite subset of all integers because each integer is only allowed a certain number bits. The number of bits allocated for any integer is sometimes called a word-length . Using 16-bit integer word-length, the integer N = 231 may be stored as 0 000000011100111. The first of the 16 bits stores the sign of the number (here "positive" is stored as 0), while the remaining 15 bits store the number itself using the binary system representation.
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern