Meghna ppt.

24
Data Data Representation Representation (in computer (in computer system) system)

Transcript of Meghna ppt.

Page 1: Meghna ppt.

Data Data RepresentationRepresentation(in computer (in computer

system)system)

Page 2: Meghna ppt.

Data RepresentationData RepresentationData RepresentationData RepresentationHow do computers represent data?How do computers represent data?

Most computers are digital

• Recognize only two discrete states: on or off

• Computers are electronic devices powered by electricity, which has only two states, on or off

Page 3: Meghna ppt.

1 1 1 1 1

0 0 0 0 0

on

off

Page 4: Meghna ppt.

Data Data RepresentationRepresentation

Data Data RepresentationRepresentationWhat is the binary system?What is the binary system?

A number system that has just two unique digits, 0 and 1

• A single digit is called a bit (binary digit)

• A bit is the smallest unit of data the computer can represent

• By itself a bit is not very informative The two digits represent the two off and on

states

Page 5: Meghna ppt.

Binary Digit (bit) Electronic Charge

Electronic State

Page 6: Meghna ppt.

Data Data RepresentationRepresentation

Data Data RepresentationRepresentation What is a byte?What is a byte?

Eight bits are grouped together to form a byte

0s and 1s in each byte are used to represent individual characters such as letters of the alphabet, numbers, and punctuation

Page 7: Meghna ppt.

8-bit byte for the number 3

8-bit byte for the number 5

8-bit byte for the capital letter T

Page 8: Meghna ppt.

Data RepresentationData RepresentationData RepresentationData RepresentationWhat are two popular coding systems What are two popular coding systems to represent data?to represent data?

American Standard Code for Information Interchange (ASCII)

Extended Binary Coded Decimal Interchange Code (EBCDIC)

• Sufficient for English and Western European languages

• Unicode often used for others

Page 9: Meghna ppt.
Page 10: Meghna ppt.

Data RepresentationData RepresentationData RepresentationData RepresentationHow is a character sent from the keyboard to the computer?How is a character sent from the keyboard to the computer?

Step 1:

The user presses the letter T key on the keyboard

Step 2:

An electronic signal for the letter T is sent to the system unit

Step 3:

The signal for the letter T is converted to its ASCII binary code (01010100) and is stored in memory for processing

Step 4:After processing, the binary code for the letter T is converted to an image on the output device

Page 11: Meghna ppt.
Page 12: Meghna ppt.

Decimal to Binary Conversions

•In an earlier slide, we said that every integer value can be represented exactly using any radix system.

•You can use either of two methods for radix a conversion: the subtraction method and the division remainder method.

The subtraction method is more intuitive, but cumbersome. It does, however reinforce the ideas behind radix mathematics.The division method employs the idea that successive division by a base is equivalent to successive subtraction by powers of the base.

Page 13: Meghna ppt.

Decimal to Binary Conversions D

•Fractional decimal values have nonzero digits to the right of the decimal point.•Fractional values of other radix systems have nonzero digits to the right of the radix point.•Numerals to the right of a radix point represent negative powers of the radix:

0.4710 = 4 10 -1 + 7 10 -2

0.112 = 1 2 -1 + 1 2 -2

= ½ + ¼ = 0.5 + 0.25 = 0.75

Page 14: Meghna ppt.

Decimal to Binary Conversions

•As with whole-number conversions, you can use either of two methods: a subtraction method and an easy multiplication method.

•The subtraction method for fractions is identical to the subtraction method for whole numbers. Instead of subtracting positive powers of the target radix, we subtract negative powers of the radix.

•We always start with the largest value first, n -1, where n is our radix, and work our way along using larger negative exponents

Page 15: Meghna ppt.

Decimal to Binary Conversions•HoweverThe binary numbering system is the most important radix system for digital computers.

•, it is difficult to read long strings of binary numbers-- and even a modestly-sized decimal number becomes a very long binary number.

For example: 110101000110112 = 1359510

•For compactness and ease of reading, binary values are usually expressed using the hexadecimal, or base-16, numbering system.

Page 16: Meghna ppt.

Decimal to Binary Conversions

•The hexadecimal numbering system uses the numerals 0 through 9 and the letters A through F.

The decimal number 12 is C16.

The decimal number 26 is 1A16.•It is easy to convert between base 16 and base 2, because 16 = 24.•Thus, to convert from binary to hexadecimal, all we need to do is group the binary digits into groups of four.A group of four binary digits is called a hextet

Page 17: Meghna ppt.

Decimal to Binary Conversions

•Using groups of hextets, the binary number 110101000110112 (= 1359510) in hexadecimal is:

•Octal (base 8) values are derived from binary by using groups of three bits (8 = 23):

Octal was very useful when computers used six-bit words

Page 18: Meghna ppt.

Signed Integer Representation

•Several representations exist for negative values: Sign Magnitude One's Complement Two's Complement 000 = +0 000 = +0 000 = +0 001 = +1 001 = +1 001 = +1 010 = +2 010 = +2 010 = +2 011 = +3 011 = +3 011 = +3 100 = -0 100 = -3 100 = -4 101 = -1 101 = -2 101 = -3 110 = -2 110 = -1 110 = -2 111 = -3 111 = -0 111 = -1

Page 19: Meghna ppt.

Signed Integer Representation

Page 20: Meghna ppt.

A B carry_in carry_out S0 0 0 0 00 0 1 0 10 1 0 0 10 1 1 1 01 0 0 0 11 0 1 1 0

•Given a full adder (FA), we can use it to add binary digits (up to 3)

Page 21: Meghna ppt.

Signed Integer RepresentationSigned Integer Representation

• Several FA's can be used to add binary numbers Several FA's can be used to add binary numbers by feeding out the carry_out one FA to the carry_in by feeding out the carry_out one FA to the carry_in of the FA of the left.of the FA of the left.

1-bit FA

S0

A0

B0

1-bit FA

S31

A31

B31

1-bit FA

S1

A1

B1

1-bit FA

S2

A2

B2

add/sub

C0

C1

C2

C3

C31

C32

32-bit Ripple Carry Adder/Subtractor (Better: Carry Lookahead Adder)

Note: add/sub is ON (1) if we want A-B, otherwise is OFF

Page 22: Meghna ppt.

•Booth’s algorithm-Multiplier and multiplicand are placed in registers Q & M-Q-1, 1-bit register placed to the right of Q0

Initialize A (third register) and Q-1 to 0Do n times (n is the number of bits in Q):

If Q0Q-1 = 01 then A <-- A + MIf Q0Q-1 = 10 then A <-- A – MArithmetic shift right A, Q, Q-1

Page 23: Meghna ppt.
Page 24: Meghna ppt.