Bits and Bytes

8
Page 1 Data Structures in C for Non-Computer Science Majors Kirs and Pflughoeft Bits and Bytes There was one other problem with There was one other problem with bytes: bytes: Compatibility Compatibility Given the binary sequences : 0000000 0000001 0000010 0000011 1111110 1111101 1111110 1111111 Manufacturers Interpreted them Manufacturers Interpreted them differently differently Manufact . #1: A B C D 6 7 8 9 Manufact . #2: 0 1 2 3 v x y z Manufact . #3: + - * ? TAB CR LF FF ASCII/EBCDIC

description

Bits and Bytes. ASCII/EBCDIC. There was one other problem with bytes: Compatibility. Given the binary sequences:. Manufact. #1:. Manufact. #2:. Manufact. #3:. A. 0. +. 0000000. B. 1. -. 0000001. C. 2. *. 0000010. D. 3. ?. 0000011.   .   .   . - PowerPoint PPT Presentation

Transcript of Bits and Bytes

Page 1: Bits and Bytes

Page 1

Data Structures in C for Non-Computer Science Majors

Kirs and Pflughoeft

Bits and Bytes

There was one other problem with bytes:There was one other problem with bytes:• CompatibilityCompatibilityGiven the

binary sequences:

0000000000000100000100000011

1111110111110111111101111111

Manufacturers Interpreted them differentlyManufacturers Interpreted them differently

Manufact.#1:

A BCD

6789

Manufact.#2:

0123

vxyz

Manufact.#3:

+-*?

TABCRLFFF

ASCII/EBCDIC

Page 2: Bits and Bytes

Page 2

Data Structures in C for Non-Computer Science Majors

Kirs and Pflughoeft

Bits and Bytes

Which is the Correct Interpretation???Which is the Correct Interpretation???

Each is equally CorrectEach is equally Correct

• 0000010 CouldCould be either a ‘C’ OR a ‘2’• The letter ‘C’ CouldCould be pronounced either ‘cee’ OR ‘ess’

What’s the Solution ???What’s the Solution ???

ASCIIASCII

The AAmerican SStandard CCode for

IInformation IInterchange

Page 3: Bits and Bytes

Page 3

Data Structures in C for Non-Computer Science Majors

Kirs and Pflughoeft

Bits and Bytes

Sample ASCII Codes:Sample ASCII Codes:Binary Sequence0000000

Value0

CharacterNULL

Description . NULL/Tape feed

0000111 7 BEL Rings Bell0001000 8 BS Back Space

0001101 13 CR Carriage Return

0011011 27 ESC Escape

0100000 32 SP Space

0110000 48 0 Zero0110001 49 1 One

1000001 65 A Capital ‘A’1000010 66 B Capital ‘B’

1100001 97 a Lower Case ‘a’1100010 98 b Lower Case ‘b’

Page 4: Bits and Bytes

Page 4

Data Structures in C for Non-Computer Science Majors

Kirs and Pflughoeft

Bits and Bytes

A Preview of Things to Come:A Preview of Things to Come:

For the first Exam MemorizeMemorize the Numeric Values for:

• NULL Value: 0• BEL (Ring The Bell) Value: 7 • BS (Backspace) Value: 8• CR (Carriage Return) Value: 13• ESC (Escape) Value: 27• SP (Space) Value: 32• The digits (0, 1, …, 9) NOTE: The Digit 0 (zero) has the value: 48• The Uppercase Alphabet NOTE: The Character ‘A’ has the value: 65• The Lowercase Alphabet NOTE: The Character ‘a’ has the value: 97

Page 5: Bits and Bytes

Page 5

Data Structures in C for Non-Computer Science Majors

Kirs and Pflughoeft

Bits and Bytes

Are We limited to only 128 (= 2Are We limited to only 128 (= 277) characters ??) characters ??

• The STANDARD ASCII Character Set Consists of 128 Characters (as given in Addendum 1.1)

Yes and no:

There is an EXTENDED ASCII Character set which uses ALL 8-bits (1-byte) available (parity is NOT an issue)• The extended ASCII Character set consists of 256

(= 28) characters (See Addendum 1.2)

• The Majority of the characters included in the extended ASCII character set are extensions of the Greco-Roman Alphabet (e.g., ß, Ü, å) or ‘graphics’ characters (e.g., )

Page 6: Bits and Bytes

Page 6

Data Structures in C for Non-Computer Science Majors

Kirs and Pflughoeft

Bits and Bytes

What does the term ‘ASCII file’ Mean ??What does the term ‘ASCII file’ Mean ??An ASCII File assumes that every 8-bits (1-byte) in the file are grouped together according to the ASCII tables

Aren’t ALL Files ASCII Files ??Aren’t ALL Files ASCII Files ??

NONO - As we will see later, not all data is stored according to ASCII formats

That Helps (sort-of) to explain why when we display non-ASCII files we sometimes get characters such as , , , , , and

Page 7: Bits and Bytes

Page 7

Data Structures in C for Non-Computer Science Majors

Kirs and Pflughoeft

Bits and Bytes

Do ALL computers use ASCII to Represent Do ALL computers use ASCII to Represent Symbols???Symbols???

NONO - Although most do.

IBM had the first Coding Scheme (dating back to 1880)

EBCDICEBCDIC

EExtended BBinary CCoded DDecimal IInterchange CCode

EBCDIC is still used in IBM Mainframes and to store data on large reel-to-reel Tape Drives

Page 8: Bits and Bytes

Page 8

Data Structures in C for Non-Computer Science Majors

Kirs and Pflughoeft

Repeat Slides for this Section

Go To Slide Index For Chapter 1

Go To Slide Index For Chapter 2

Go To Slide Index For Textbook

Go To Home Page

This Concludes The Slides for this Section

Choose an Option: