Lecture 22: Number Systems

Slides:



Advertisements
Similar presentations
Continuation of chapter 6…. Nested while loop A while loop used within another while loop is called nested while loop. Q. An illustration to generate.
Advertisements

Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 3: Flow Control I: For Loops.
Base 10 Denary Decimal
Bit Representation Outline
Binary & Decimal numbers = 3* * *10 + 5*1 = 3* * * *10 0 Decimal system: Ten digits: 0,1,2,3,…,9 Example:
Random (1) Random class contains a method to generate random numbers of integer and double type Note: before using Random class, you should add following.
Binary Mathematics. Counting system There are three kinds of people in the world: those who can count, and those who can not. - Unknown Wisdom Today’s.
CS1800 Summer 2014 Binary Numbers. Decimal Integers  What does a decimal number like "87294" really mean?  More generally.
Binary numbers and arithmetic. ADDITION Addition (decimal)
Numbering Systems CS208.
The string data type String. String (in general) A string is a sequence of characters enclosed between the double quotes "..." Example: Each character.
Number System. Number Systems Important Number systems – Decimal – Binary – Hexadecimal.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Bits and Bytes. Decimal Numbers 6,357 has four digits -base-10 (6 * 1000) + (3 * 100) + (5 * 10) + (7 * 1) = = 6357 (6 * 10^3) + (3.
CSE115: Introduction to Computer Science I Dr. Carl Alphonce 343 Davis Hall
1 COMS 161 Introduction to Computing Title: The Digital Domain Date: September 6, 2004 Lecture Number: 6.
Digital Representations ME 4611 Binary Representation Only two states (0 and 1) Easy to implement electronically %0= (0) 10 %1= (1) 10 %10= (2) 10 %11=
Number Representation Lecture Topics How are numeric data items actually stored in computer memory? How much space (memory locations) is.
Chapter One Lesson Three DATA TYPES ©
1 COMS 161 Introduction to Computing Title: Computing Basics Date: September 8, 2004 Lecture Number: 7.
CEC 220 Digital Circuit Design Binary Codes Mon, Aug 31 CEC 220 Digital Circuit Design Slide 1 of 14.
A data type in a programming language is a set of data with values having predefined characteristics.data The language usually specifies:  the range.
Introduction to Number Representation A451 GCSE Computing.
Binary and Hexadecimal Numbers CSE 1310 – Introduction to Computers and Programming Vassilis Athitsos University of Texas at Arlington 1.
Introduction to Computer Science What is Computer Science? Getting Started Programming.
Topic: Binary Encoding – Part 2
Binary & Decimal numbers
Lecturer: Santokh Singh
Topic: Binary Encoding – Part 1
Binary and Hexadecimal Numbers
Data Representation Lesson 2 Binary KS3 COMPUTING KS3 Computing
Data representation How do we represent data in a digital system?
How Computers Store Variables
using System; namespace Demo01 { class Program
COUNTING IN BINARY Binary weightings 0 x x x x 8
Chapter 2.
Binary Code  
Computing Adjusted Quiz Total Score
BCD = Binary Coded Decimal
TO COMPLETE THE FOLLOWING:
An Introduction to Java – Part I, language basics
CDA 3100 Summer 2013.
Binary Lesson 3 Hexadecimal
Binary Lesson 2 Bytes.
CSE 143 Lecture 2 Collections and ArrayIntList
Building Java Programs
CSE 143 Lecture 11 Recursive Programming slides created by Marty Stepp
Java Lesson 36 Mr. Kalmes.
Binary Lesson 2 Bytes.
Binary Lesson 3 Hexadecimal
Binary Lesson 3 Hexadecimal
COMS 161 Introduction to Computing
Binary Lesson 2 Bytes.
class PrintOnetoTen { public static void main(String args[]) {
Starter Using the fingers on only one hand, what is the highest number you can count to? Rules: You must start at 1 You must count sequentially (i.e.
Binary Lesson 3 Hexadecimal
Data representation How do we represent data in a digital system?
The Binary System.
COUNTING IN BINARY Binary weightings 0 x x x x 8
slides created by Alyssa Harding
Binary Lesson 4 Hexadecimal and Binary Practice
Art without Engineering is dreaming
Building Java Programs
Data representation How do we represent data in a digital system?
slides created by Alyssa Harding
Lecture 35 – Unit 6 – Under the Hood Binary Encoding – Part 1
Lecture 36 – Unit 6 – Under the Hood Binary Encoding – Part 2
Lecture 37 – Practice Exercises 9
1 1. Binary Basics Year 8 Unit 1 Bitmap Graphics.
Lecture 37 – Practice Exercises 9
Presentation transcript:

Lecture 22: Number Systems Adapted from York University Intro to IT Slides.

Base 10 (Decimal numbers) Why base 10? We happened to use the current counting system, because we happened to have ten fingers. Base 10(Decimal) uses 10 digits {0,1,2,3…,9}.

Example

Example

Example

Example

Example

Example

Example

Bits and Bytes 1 bit is a single bit of information, a 1 or 0 Only two possible values 1 byte is 8 bits, an 8 bit word 256 possible values from 0-255 base 10 or 00000000 to 11111111 base 2 10100110 is a single byte

Bits and Bytes Java integer type int uses 32 bits. Its maximum value is 2^31 – 1. Its minimum value is -2^31. We can access these values through the Integer class. public static void main(String[] arg) { System.out.println(Integer.MAX_VALUE); System.out.println(Integer.MIN_VALUE); } Output: 2147483647 -2147483648

Counting Let’s count in Base 10. 0,1,2,3,4,5,6,7,8,9,__,___,…,18,19,__,__. Answer: 10,11,20,21. Impressive… Let’s count in Base 5. 0,1,2,3,4,__,__,__,__,__,___. Answer:10,11,12,13,14,20. Let’s keep going! 40,41,42,43,44,___,___,___. Answer:100,101,102.

Adding Binary 0+0=0 1+0=1 1+1=10

Quick Quiz What’s the answer in base 8? What’s the answer in base 5? What’s the answer in base 12?

People There are 10 types of people in the world; those who understand binary and those who don’t. There are 10 types of people in the world; those who understand binary and those who have friends.

Encoding Data in Binary 24-bit image What is an image? an audio file? a movie? It is simply an array of 0s and 1s!

Homework Complete the number system worksheet. Write the method decimalToBinary which accepts an integer and returns the string representation of the decimal integer in binary. public static String decimalToBinary(int n){ }