class 3 binary & hexadecimal

14
BINARY & HEXADECIMAL Class 3 – Number Systems II

Upload: stephen-parsons

Post on 18-Nov-2014

2.029 views

Category:

Education


5 download

DESCRIPTION

In this third class we will continue our exploration of positional number systems, switching gears to examine binary and hexadecimal systems. We will also examine a problem-solving approach that is used by programmers - the IPO method.

TRANSCRIPT

Page 1: Class 3 Binary & Hexadecimal

BINARY & HEXADECIMALClass 3 – Number Systems II

Page 2: Class 3 Binary & Hexadecimal

Introduction

Positional Number Systems Decimal Binary Hexadecimal

The Power of Two

Page 3: Class 3 Binary & Hexadecimal

Agenda

Review from Week 2 Binary

Translating between Binary & Decimal Binary Math

Hexadecimal Numbers Converting between Binary & Hex Converting between Decimal & Hex

IPO Approach to Problem-Solving Ruby on Flash

Page 4: Class 3 Binary & Hexadecimal

Positional Number Systems

Decimal positioning (fingers and toes)

107 106 105 104 103 102 101 100

10,000,000 1,000,000 100,000 10,000 1000 100 10 1

123,456

Page 5: Class 3 Binary & Hexadecimal

Positional Number Systems

Binary Number System

210 29 28 27 26 25 24 23 22 21 20

1024 512 256 128 64 32 16 8 4 2 1

10101110

Page 6: Class 3 Binary & Hexadecimal

Binary-Decimal Conversion

Notation10110112 (base 2 – or binary)

Convert Binary to Decimal Use positional grid and add up values e.g. 11012 ? 10012? 01102? 10002?

Convert Decimal to Binary Divide into largest position, then use

modulus e.g. 34510? 79110? 23310 ?

Practice Exercises

Page 7: Class 3 Binary & Hexadecimal

Binary Mathematical Operations

Adding and Multiplying Binary

Subtracting and Dividing Binary102-12=12

Practice Exercises

1001 1101 1000 1101 1110 1101+101 +111 +101 x100 x111 x101

1001 1101 1000 110001 ÷ 111 111111 ÷ 1001 -101 -111 -101

Page 8: Class 3 Binary & Hexadecimal

Positional Number Systems

Hexadecimal

A60F

164 163 162 161 160

65536

4096 256 16 1

Page 9: Class 3 Binary & Hexadecimal

Hex-Binary-Decimal Conversion

Notation101101116 (base 16 – or hexadecimal)

Convert Binary to Hex Nibbles & Tribbles 101111010001 = 1011 1101 0001 =

BD1 Handout: Conversion Chart (also on

site) Convert Decimal to Hex

Divide into largest position, then use modulus

Practice Exercises

Page 10: Class 3 Binary & Hexadecimal

A Functional Example

Color Name RD GR BL HEX Sample

Black 0 0 0 000000

White 255 255 255 FFFFFF

Grey 140 140 140 8C8C8C

Teal 0 128 128 008080

Maroon 202 74 12 CA4A12

Navy 0 0 128 000080

Page 11: Class 3 Binary & Hexadecimal

Quest: Problem-Solving Approaches

Various Approaches Step-by-step Algorithmic Heuristic Programmatic

IPO – input, processing, output Refer to handout

Group Exercise: Confusion at the restaurant Debrief

Page 12: Class 3 Binary & Hexadecimal

Quest II: Ruby on a Flash Drive

Ruby on Flash – downloading and unpacking http://rubyinstaller.org/downloads Unpack to root of drive

Setting Path Path command? Rubyset.bat commands

Testing the installation with command prompt C:\ ruby -v

Page 13: Class 3 Binary & Hexadecimal

Summary

Binary Number System, Operations and Conversion

Hexadecimal Number System and Conversion Practical use of Hexadecimal

Quest 1: IPO Approach Quest II: Ruby on Flash

Next Class: Intro to Ruby Programming

Page 14: Class 3 Binary & Hexadecimal

Assignment

Assignment 1: Math Review I Due start of next class Hand-in