# BITS, BYTES, AND THE BINARY SYSTEM HOW PROGRAMS CREATE IMAGES ON YOUR PC.

## Presentation on theme: "BITS, BYTES, AND THE BINARY SYSTEM HOW PROGRAMS CREATE IMAGES ON YOUR PC."— Presentation transcript:

BITS, BYTES, AND THE BINARY SYSTEM HOW PROGRAMS CREATE IMAGES ON YOUR PC

THE LANGUAGE OF PROGRAMMING Computers are programmed using a code made up of binary digits (bits) One bit is a single unit of binary code, either a 0 or 1 0 and 1 are the ONLY possible binary digits (we’ll explore that code later) Using binary code to represent specific values allows the programmer to create virtually unlimited permutations in the form of letters, graphics, colors, and instructions.

THINK OF A LIGHT SWITCH A light switch has TWO positions; ON and OFF When the switch is ON, power flows to the light When the switch is OFF, no power flows to the light

NOW, IMAGINE GROUPS OF SWITCHES WITH EACH SWITCH EITHER ON OR OFF Can you read the message?

WHEN THE “ON” SWITCHES ARE ILLUMINATED, THE “CODED” MESSAGE BECOMES CLEAR

BYTES ARE GROUPS OF 8 BITS The light switch example is, of course, a simplified way of looking at programming. In reality, bits are most commonly arranged in groups of 8 called “bytes.” Each byte in a program represents a small amount of information, such as a single letter of the alphabet.

PACKETS ARE GROUPS OF BYTES Obviously, there’s more to it! A byte doesn’t contain much information, so if you want to write a whole word, you need many bytes. Bytes are arranged into larger groups called “packets.” In programming, packets are separated by “headers” to show where each new packet begins. Generally, packets contain between 7 and 65,542 bytes, including their headers.

WHY BINARY CODE? Binary is a numbering code, just as decimal is a numbering code. You know that the decimal system is written in place values representing ones, tens, hundreds, thousands, and so on. The decimal system uses symbols to represent up to 9 individual things. After that, you have to multiply to find the value of digits in specific places in a number: 4,268 = 4,000+200+60+8 OR (4x1000) + (2x100) + (6x10) + (8x1) This is standard notationThis is expanded notationThis is scientific notation

BINARY HAS ONLY TWO DIGITS, 0 AND 1 Just as the decimal (“ten”) system has ten digits, 0 through 9, the binary (“two”) system has only two digits, 0 and 1 The decimal system increases the value of each digit by a power of 10 The binary system increases each digit by the power of 2 If you apply the same system of “powers” used in the decimal system to the binary system, the pattern becomes clear…

COMPARE DECIMAL AND BINARY 10 3 10 2 101 (x1000) “thousands” (x100) “hundreds” (x10) “tens” (x1) “ones” 5682 5,682 (5000+600+80+2) (5x100)+(6x100)+(8x10)+(2x1) 23232 21 (x8) “eights” (x4) “fours” (x2) “twos” (x1) “ones” 1101 13 (8+4+1) (1x8)+(1x4)+(1x1) Decimal Place ValuesBinary Place Values

A QUICK SIDE TRIP TO LOOK AT “PIXELS” Pixels are tiny “lamps” on your PC monitor A single pixel is smaller than the head of a pin Each pixel is “attached” to a “light switch” in the circuitry of your PC’s motherboard Illuminating sets of pixels, just like our wall of light switches, reveals patterns that we easily recognize In the early days of computing, pixels were much larger, and that’s why everything looked like it was drawn with little boxes – Like this… and this!

HAVE YOU FIGURED OUT WHY WE USE BINARY? Programmers began using binary code BECAUSE it has only two digits Two digits means one digit can represent “on” and the other can represent “off” Remember, “on” and “off” are all about whether or not power (electricity) is applied to that position. By sending power to individual “pixels” on your PC monitor, patterns emerge that look like letters or anything else you want to represent!