week02

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

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

View Full Document Right Arrow Icon
CS 177 Week 2: Primitive Data Types 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
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
Background image of page 2
What did we talk about last week? Other Java features: Sequencing commands Whitespace insensitivity Case sensitivity Comments 3
Background image of page 3

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

View Full DocumentRight Arrow Icon
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
Background image of page 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
Background image of page 5

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

View Full DocumentRight Arrow Icon
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
Background image of page 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
Background image of page 7

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

View Full DocumentRight Arrow Icon
Base 10 Example 3 , 4 8 2 , 9 3 1 Ones Millions Hundreds Thousands Tens Hundred thousands Ten thousands 8
Background image of page 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
Background image of page 9

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

View Full DocumentRight Arrow Icon
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
Background image of page 10
So, what’s the value? 11111011001 =
Background image of page 11

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

View Full DocumentRight Arrow Icon
Image of page 12
This is the end of the preview. Sign up to access the rest of the document.

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 Right Arrow Icon
Ask a homework question - tutors are online