class 3 binary & hexadecimal
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
BINARY & HEXADECIMALClass 3 – Number Systems II
Introduction
Positional Number Systems Decimal Binary Hexadecimal
The Power of Two
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
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
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
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
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
Positional Number Systems
Hexadecimal
A60F
164 163 162 161 160
65536
4096 256 16 1
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
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
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
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
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
Assignment
Assignment 1: Math Review I Due start of next class Hand-in