binary concepts review

27
Let’s review some binary concepts Leo Hernandez Intro to Computer Science 2014-2015 11-13-2014

Upload: leo-hernandez

Post on 14-Apr-2017

36 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Binary Concepts Review

Let’s review some binaryconceptsLeo Hernandez

Intro to Computer Science 2014-201511-13-2014

Page 2: Binary Concepts Review

Binary ConceptsHow do computers store and processinformation?

Page 3: Binary Concepts Review

Binary ConceptsHow do computers store and processinformation? Computers store and process information in aseries of bits

Page 4: Binary Concepts Review

Binary ConceptsHow much information can be represented inbits?

Page 5: Binary Concepts Review

Binary Concepts1 bit=2 values (0,1)

Page 6: Binary Concepts Review

Binary Concepts1 nibble (half byte, 4 bits)=16 values

Page 7: Binary Concepts Review

Binary Concepts1 byte (8 bits)=256 values

Page 8: Binary Concepts Review

Binary Concepts2 bytes (16 bits)=65,536 values

Page 9: Binary Concepts Review

Binary Concepts4 bytes (32 bits)=4,294,967,296 values That’s over 4 BILLION

Page 10: Binary Concepts Review

Binary Concepts8 bytes (64 bits)=1.84467440737096 x 1019 values That is a seriously huge number!

Page 11: Binary Concepts Review

Binary ConceptsWhat is the pattern?

Page 12: Binary Concepts Review

Binary ConceptsWhat is the pattern? As we double the number of bits, the number ofvalues that can be represented growsexponentially.This is the key in how computers are able toprocess so much data.

Page 13: Binary Concepts Review

Binary ConceptsFormula to calculate the total values that canbe represented in a number of bits Total Values = 2number of bits Example: 216 = 65,536

Page 14: Binary Concepts Review

Binary ConceptsName the most common number systems thatwe use in Computer Science

Page 15: Binary Concepts Review

Binary ConceptsName the most common number systems thatwe use in Computer Science (hint: there’s 4 of them)

Page 16: Binary Concepts Review

Binary ConceptsName the most common number systems thatwe use in Computer ScienceBinary: 0b01Octal: 0o01234567Decimal: 0123456789Hexadecimal: 0x0123456789ABCDEF

Page 17: Binary Concepts Review

Binary ConceptsConverting from Decimal to Binary Many different ways of doing this:Personally, I like the division method where youkeep dividing by 2 and keeping track of theremainder to convert.

Page 18: Binary Concepts Review

Binary Concepts

Page 19: Binary Concepts Review

Binary ConceptsConverting from Binary to Decimal Take each bit and multiply it by itscorresponding power, then add up the values

Page 20: Binary Concepts Review

Binary ConceptsConverting between hexadecimal and binary Use the table that I provided to you

Page 21: Binary Concepts Review

Binary ConceptsBinary addition Functions just like regular addition except only1s and 0s are allowed.

Page 22: Binary Concepts Review

What is an integer?

Page 23: Binary Concepts Review

What is an integer?An integer are all whole numbers and theircorresponding negative values (including 0)

Page 24: Binary Concepts Review

Signing Integers3 ways: Signed MagnitudeOne’s ComplementTwo’s Complement Which is better and most widely used? Why?

Page 25: Binary Concepts Review

Signing IntegersOne major side effect of signing integers is thatthe total number of values represented by bitsis halved. For example: 1 = 256 unsigned values but only128 signed values (-128 … 0 … 127)

Page 26: Binary Concepts Review

Signing IntegersThis is important because in most languages,signed integers are typically used by default

Page 27: Binary Concepts Review

Signing Numbers Questions?