week02

# week02 - Week 2 Primitive Data Types CS 177 1 What did we...

This preview shows pages 1–12. Sign up to view the full content.

CS 177 Week 2: Primitive Data Types 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
What did we talk about last week? Programming in Java Everything goes inside a class The main() method is the starting point for executing instructions We can use System.out.println() to print information 2
What did we talk about last week? Other Java features: Sequencing commands Whitespace insensitivity Case sensitivity Comments 3

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Data What if you want to write a Java program that can… Edit music files Play a DVD Organize your photo album Each of these tasks manipulates a lot of data MP3’s, DVD’s, and jpegs are complicated kinds of data 4
Binary Hardware You have heard about all the 1 ’s and 0 ’s inside a computer What does that really mean? Using semiconductor physics, we can make a tiny little piece of a microchip be in one of two states, say, OFF and ON , like a switch If we say that OFF is 0 and ON is 1 , then, by using a lot of these switches, we can 5

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Binary Representation What do we do with those 1 ’s and 0 ’s? To begin with, we represent numbers How many of you have heard of base 10? How many of you have heard of base 2? What’s the definition of a number system with a given base? 6
Base 10 (decimal) numbers Our normal number system is base 10 This means that our digits are: 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9 Base 10 means that you need 2 digits to represent ten, namely 1 and 0 Each place in the number as you move left corresponds to an increase by a factor of 10 7

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Base 10 Example 3 , 4 8 2 , 9 3 1 Ones Millions Hundreds Thousands Tens Hundred thousands Ten thousands 8
Base 2 (binary) numbers The binary number system is base 2 This means that its digits are: 0 and 1 Base 2 means that you need 2 digits to represent two, namely 1 and 0 Each place in the number as you move left corresponds to an increase by a factor of 2 instead of 10 9

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Base 2 Example 1 1 1 1 1 0 1 1 0 0 1 Ones 1024’s Sixteens Thirty twos Eights Sixty fours Twos Fours 256’s 128’s 512’s 10
So, what’s the value? 11111011001 =

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 02/23/2012 for the course CS 177 taught by Professor Staff during the Spring '08 term at Purdue.

### Page1 / 36

week02 - Week 2 Primitive Data Types CS 177 1 What did we...

This preview shows document pages 1 - 12. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online