Binary and Decimal Numbers

Download Report

Transcript Binary and Decimal Numbers

Binary and Decimal Numbers
CSCI-N 100
Dept. Computer & Information Science
Numbers in computers
Originally designed to crunch numbers




Eckert and Mauchly (and scores more)
Univ. Penn, Moore School of Elec. Eng.
(and lots of other places)
Long- range firing solutions in WW II (and
other problems)
ENIAC (and many more machines and
devices)
Power in the numbers
Electrical power into computer


Series of switches opening and closing
Converts analog into digital (self-correcting
switches make it high accurate digital
device)
The divided machine
Analog

Digital
Nearly infinite in
precision but limited
accuracy
1
on
High
Low
Off
0

Limited precision but
strongly accurate
What the computer doesn’t
understand
Letters
Graphics
Colors
Characters
Sound
Other types of data
Making the computer
understand
Convert what we know to something
the computer understands
Converting analog to digital
Switches opening and closing


Open
Closed
On
Off
1
0
Making the user understand
Computer sending back information to
the user
Converting the 1s and 0s into
something the user understands
Representation
Calendar

Represents
movement of the
Earth around the Sun
Temperature

 Sun’s ray reflecting of
Earth surface
 Interaction of
reflective rays with
molecule in the
atmosphere
 Excited molecules
generate heat
Time


Represents a given
amount of
movement of the
Earth
Clock
Represents

Thermometer
The Numbers
Binary – Base 2

0, 1
Decimal – Base 10

0–9
Other number bases


Octal – Base 8 (0 – 7)
Hexadecimal – Base 16 (0 – 9, a – f)
How the computer deals with
numbers
Real numbers (infinite)



Pi
1/3 (.3333)
Not enough computer memory
Infinitely precise
Uses round-off error (also called
floating point)
Sound, Graphics, Text?
Not represented in a ‘natural’, numeric
way
Need to convert bits of information from
analog to ‘digital information’
Representing text
Text represented by ASCII


Original ASCII 7-bit character (27 = 128)
Extended ASCII 8-bit character (28 = 256)
 Uses Western European English character set

UNICIODE
 65,000 character set coding scheme
 Used for languages that use glyphs




Chinese
Arabic
Hebrew
EBCDIC 8-bit code
Representing graphics
Pixel



Dot on in the image assigned numeric
value
Translate to monitor
Graphics use hexadecimal coding for use in
web pages on the Internet
 Red Green Blue (RRGGBB)
GIF, JPG, PNG, BMP, TIF
(and lots more)
Representing sound
MIDI (developed 1982 my music industry)
AU (supported by many different software systems over a
large range of platforms)
RealAudio (developed by Real Media for Internet use)
AIFF (developed by Apple)
SND (developed by Apple)
MP3 (developed by Moving Pictures Experts Group)
WAVE (developed by IBM and Microsoft)
Base 10 to Base 2
28
27
26
256 128 64
1
1
25
32
1
24
16
0
23
8
0
22
4
1
21
2
1
20
1
0
Find the binary number that is EQUAL TO BUT LESS THAN the decimal
number, SUBTRACT
23010
6–4=2
230 – 128 = 102
2–2=0
102 – 64 = 38
23010 = 111001102
38 – 32 = 6
6 – 16, cannot subtract
6 – 8, cannot subtract
Base 2 to Base 10
28
27
26
25
24
23
22
21
20
256 128 64
1
1
1
32
1
16
0
8
0
4
1
2
1
1
0
ADD the BINARY switches turned on, reading left to right
1111001102 = 48610
256
+128
+64
+32
+0
+0
+4
+2
+0