Binary Concepts Review

Post on 14-Apr-2017

39 views 0 download

Transcript of Binary Concepts Review

Let’s review some binaryconceptsLeo Hernandez

Intro to Computer Science 2014-201511-13-2014

Binary ConceptsHow do computers store and processinformation?

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

Binary ConceptsHow much information can be represented inbits?

Binary Concepts1 bit=2 values (0,1)

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

Binary Concepts1 byte (8 bits)=256 values

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

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

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

Binary ConceptsWhat is the pattern?

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.

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

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

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

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

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.

Binary Concepts

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

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

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

What is an integer?

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

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

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)

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

Signing Numbers Questions?