©1999 addison wesley longman2.1 a bit about bits a bit (binary digit) –is the smallest unit of...

21
©1999 Addison Wesley Longman 2.1 A Bit About Bits A bit (binary digit) is the smallest unit of information can have two values - 1 and 0. Binary digits, or bits, can represent numbers, codes, or instructions. On Off

Upload: rebecca-booth

Post on 18-Dec-2015

217 views

Category:

Documents


0 download

TRANSCRIPT

©1999 Addison Wesley Longman 2.1

A Bit About Bits

A bit (binary digit)– is the smallest unit of

information– can have two values

- 1 and 0.

Binary digits, or bits, can represent numbers, codes, or instructions.

On Off

©1999 Addison Wesley Longman 2.2

Bits as Numbers

Binary number system - a system that denotes all numbers and combinations of two digits.

The binary system uses two digits to represent the numbers 0 and 1.

©1999 Addison Wesley Longman 2.3

Number System (I)

• decimal system ( base 10 )

• octal system ( base 8 )

• binary system ( base 2 )

©1999 Addison Wesley Longman 2.4

Number System (II)

• decimal octal binary 0 0 0000 1 1 0001 2 2 0010 3 3 0011 4 4 0100 5 5 0101 6 6 0110 7 7 0111 8 10 1000 9 11 100110 12 1010

©1999 Addison Wesley Longman 2.5

To Represent Negative Numbers

• biased

• sign magnitude

• 1’s complement

• 2’s complement

©1999 Addison Wesley Longman 2.6

Biased Numbers

• decimal BCD biased0 000 -41 001 -32 010 -23 011 -14 100 05 101 16 110 27 111 3

©1999 Addison Wesley Longman 2.7

Sign Magnitude Numbers

• sign magnitude-3 1 11-2 1 10-1 1 01-0 1 000 0 001 0 012 0 103 0 11

©1999 Addison Wesley Longman 2.8

1‘s Complement Numbers

• -3 100-2 101-1 110-0 1110 0001 0012 0103 011

©1999 Addison Wesley Longman 2.9

2‘s Complement Numbers

• -4 100-3 101-2 110-1 1110 0001 0012 0103 011

©1999 Addison Wesley Longman 2.10

1‘s Complement Addition

• BCD addition• carry end around• result always correct when two operands

have different sign• overflow when two positive operands add

to a negative result• underflow when two negative operands

add to a positive result

©1999 Addison Wesley Longman 2.11

2‘s complement Addition

• BCD addition• carry dropped• result always correct when two operands

have different sign• overflow when two positive operands add

to a negative result• underflow when two negative operands

add to a positive result

©1999 Addison Wesley Longman 2.12

Floating Point Representation

• = 12345 * 10-2

= 1234.5 * 10-1

= 123.45= 12.345 * 101

= 1.2345 * 102

= 0.12345 * 103 — normalized form= 0.012345 * 104

• 21.75 = 10101.11

= 0.1010111 * 25

©1999 Addison Wesley Longman 2.13

PDP-11, VAX-11 Floating Point Representation

• precision 1/224 ~ 1/107

• range 2127 ~ 1038

0 10000101 01011100…….0

8 bits 23 bits

mantissasign

©1999 Addison Wesley Longman 2.14

IBM360/370 Floating Point Representation

• 21.75 = 10101.11B

= 15.CH

= .15C * 162

• precision 1/221 ~ 1/106

• range 1663 = 2252 ~ 1078

0 1000010 0001 0101 1100 0000 0000 0000

4 2 1 5 C 0 0 0

©1999 Addison Wesley Longman 2.15

Bits as Codes

ASCII - American Standard Code for Information Interchange - most widely used code, represents each character as a unique 8-bit code.

©1999 Addison Wesley Longman 2.16

Code & Character Sets

• ASCII ( American Standard Code for Information Interchange ) — 7 bit

0 1 2 3 4 5 6 7 8 9 A B C D E F 0 | 1 | 2 | ! “ # $ % & ` ( ) * + - , . / 3 | 0 1 2 3 4 5 6 7 8 9 4 | @A B C D E F G H I J K L M N O 5 | P Q R S T U V WX Y Z 6 | a b c d e f g h I j k l m n o 7 | p q r s t u v w x y z

©1999 Addison Wesley Longman 2.17

Code & Character Sets (IV)

• EBCDIC ( extended BCD for information exchange code ) — 8 bit

0 1 2 3 4 5 6 7 8 9 A B C D E F8 | a b c d e f g h i9 | j k l m n o p q rA | s t u v w x y zB |C | A B C D E F G H ID | J K L M N O P Q RE | S T U V W X Y ZF | 0 1 2 3 4 5 6 7 8 9

©1999 Addison Wesley Longman 2.18

Chinese Characters

• Big-5 2 byte ( 16 bit ) 13461字• CNS11643 3 byte ( 24 bit ) 48222字

©1999 Addison Wesley Longman 2.19

Bits as Instructions

The computer stores programs as collections of bits.For instance, 01101010 might instruct the

computer to add two numbers.(OP code)

Other bit instructions might include where to find numbers stored in memory or where to store them.(operands)

©1999 Addison Wesley Longman 2.20

Bits, Bytes, and Buzzwords

Common terms might describe file size or memory size:

Bit: smallest unit of information

Byte: a grouping of eight bits of information

K: (kilobyte); about 1,000 bytes of information - technically 1024 bytes equals 1K of storage.

©1999 Addison Wesley Longman 2.21

Bits, Bytes, and Buzzwords

MB: (megabyte); about 1 million bytes of information

GB: (gigabyte); about 1 billion bytes of information

TB: (terabyte); about 1 million megabytes of information