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 Digital Limited precision but strongly accurate 1 on High Low Off
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 On 1 Closed Off 0
Making the user understand Computer sending back information to the user Converting the 1s and 0s into something the user understands
Representation Calendar Time Temperature Represents movement of the Earth around the Sun Time Represents a given amount of movement of the Earth Clock Temperature Represents Sun’s ray reflecting of Earth surface Interaction of reflective rays with molecule in the atmosphere Excited molecules generate heat Thermometer
The Numbers Binary – Base 2 Decimal – Base 10 Other number bases 0, 1 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 25 24 23 22 21 20 256 128 64 32 16 8 4 2 1 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 32 16 8 4 2 1 ADD the BINARY switches turned on, reading left to right 1111001102 = 48610 256 +128 +64 +32 +0 +4 +2