COMS 161 Introduction to Computing Title: Digital Numbers Date: January 28, 2005 Lecture Number: 8
Announcements Why do sea-gulls fly over the sea? Because if they flew over the bay they would be bagels! A man left home running. He ran a ways and then turned left, ran the same distance and turned left again, ran the same distance and turned left again. When he got home there were two masked men. Who were they? A catcher and an umpire
Review Numbers Non-positional Positional Decimal Octal Binary Definition Decimal Octal Binary
Outline Numbers Unsigned and signed
Binary number system Digital and binary relationship The language of computers use binary digits Only 2 possible values 0 and 1 Much simpler to make electronics that distinguish between one of two values Distinguishing between more than two values is very difficult
Binary number system Since binary digits have two possible values Binary digits are called bits They only contain a little “bit” of information Numbers represented in binary form will (most likely) require more digits (bits) than the decimal form
Binary Number System How many values can 2 bits represent? Bit Pattern Numeric Value Item Represented 00 Black 01 1 White 10 2 Red 11 3 Green
Binary Number System How many values can 3 bits represent? Bit Pattern Numeric Value Item Represented 000 Black 001 1 White 010 2 Red 011 3 Green 100 4 Blue 101 5 Purple 110 6 Magenta 111 7 Sky blue
Binary Number System How many values can 4 bits represent? Bit Pattern 0000 1000 8 0001 1 1001 9 0010 2 1010 10 0011 3 1011 11 0100 4 1100 12 0101 5 1101 13 0110 6 1110 14 0111 7 1111 15
Binary Number System Bit patterns and numeric values are consistent with other slides Acceptable to add leading 0’s if desired
Binary number system Possible to represent more information than that of a single bit Lump together multiple bits called strings One bit: 2 values Two bits: 4 values (00, 01, 10, 11) Three bits: 8 values (000, 001, …, 111) Four bits: 16 values (0000, …, 1111) Five bits: 32 values Six bits: 64 values Seven bits: 128 values Eight bits: 256 values
Binary number system number of values = 2number of bits In general 1 = 20 2 = 21 4 = 22 8 = 23 16 = 24 32 = 25 64 = 26 128 = 27 256 = 28
Binary number system Common bit grouping’s 4 bits: nibble 8 bits: byte One byte represents 256 different values or items