Difference between revisions of "Number Systems"

From Coder Merlin
 
(5 intermediate revisions by 3 users not shown)
Line 2: Line 2:
{{MerlinCurriculumData|{{ROOTPAGENAME}}}}
{{MerlinCurriculumData|{{ROOTPAGENAME}}}}
== Experience ==
== Experience ==
{{MerlinMultipageExperience}}
{{MerlinMultipageExperienceSubpages
 
  |Pages=Positional Notation;Alternative Bases;Formal Representation;Conversions to Decimal;Conversions from Decimal;Customs;Shortcut Conversions
 
}}
{{MerlinMultipageExperienceNavBar}}
 
== Customs ==
* It is customary to separate groups of three '''decimal''' digits by commas.  For example:  123,456<sub>10</sub>.
* It is customary to separate groups to two '''hexadecimal''' digits by spaces and prefix a leading zero to what would otherwise be a single digit.  For example: 01 2F<sub>16</sub>.
* It is customary to separate groups of three '''octal''' digits by spaces and prefix leading zeros to pad to a three digit grouping.  For example: 001 237<sub>8</sub>.
* It is customary to separate groups of four '''binary''' digits by spaces and prefix leading zeroes to pad to a four digit grouping.  For example: 0001 1011 1100<sub>2</sub>.
 
== Shortcut Conversions ==
Because both the octal and hexadecimal bases contain <math>2^3</math> and <math>2^4</math> possible digits, respectively, and the binary base contains <math>2^1</math> possible digits, we're able to utilize a shortcut when converting between these systems.  Note that each octal digit is comprised of three binary digits and each hexadecimal digit is comprised of four binary digits.  We can therefore establish (and '''memorize''') the following table:
 
{| class="wikitable"
!Decimal
!Binary
!Octal
!Hexadecimal
|-
|00
|0000
|00
|0
|-
|01
|0001
|01
|1
|-
|02
|0010
|02
|2
|-
|03
|0011
|03
|3
|-
|04
|0100
|04
|4
|-
|05
|0101
|05
|5
|-
|06
|0110
|06
|6
|-
|07
|0111
|07
|7
|-
|08
|1000
|10
|8
|-
|09
|1001
|11
|9
|-
|10
|1010
|12
|A
|-
|11
|1011
|13
|B
|-
|12
|1100
|14
|C
|-
|13
|1101
|15
|D
|-
|14
|1110
|16
|E
|-
|15
|1111
|17
|F
|}
 
The shortcut is very straight-forward yet a significant time saver and based on the above information.  When converting between binary, octal, and hexadecimal, there's no need to use an intermediate, decimal step. 
 
=== Binary to Hexadecimal ===
Group the binary number in sets of four digits, from right to left.  Each binary set represents a single hexadecimal digit.  (It's sometimes helpful to pad the final set with zeroes.)  For example, given the number <math>11000111\;\;00100101_{2}</math>, regroup the binary digits in sets of four:<br/>
<math>11000111\;\;00100101_{2}</math><br/>
<math>\color{Orange}1100\color{Blue}0111\;\;\color{Orange}0010\color{Blue}0101\color{Black}_{2}</math><br/>
<math>\color{Orange}1100\;\;\color{Blue}0111\;\;\color{Orange}0010\;\;\color{Blue}0101\color{Black}_{2}</math>.<br/>
 
Then, use the memorized table to translate each set of four binary digits to a single hexadecimal digit:
 
{| class="wikitable"
| 1100
| 0111
| 0010
| 0101
|-
| C
| 7 
| 2
| 5
|}
 
=== Hexadecimal to Binary ===
Simply follow the above procedure in reverse.  Use the memorized table to convert each hexadecimal digit to a set of four binary digits.
 
=== Binary to Octal ===
Group the binary number in sets of three digits, from right to left.  Each binary set represents a single octal digit.  (It's sometimes helpful to pad the final set with zeroes.)  For example, given the number <math>11000111\;\;00100101_{2}</math>, regroup the binary digits in sets of three:<br/>
<math>11000111\;\;00100101_{2}</math><br/>
<math>\color{Orange}1\color{Blue}100\color{Orange}011\color{Blue}1\;\;00\color{Orange}100\color{Blue}101\color{Black}_{2}</math><br/>
<math>00\color{Orange}1\;\;\color{Blue}100\;\;\color{Orange}011\;\;\color{Blue}100\;\;\color{Orange}100\;\;\color{Blue}101\color{Black}_{2}</math>.<br/>
 
Then, use the memorized table to translate each set of three binary digits to a single octal digit:
 
{| class="wikitable"
| 001
| 100
| 011
| 100
| 100
| 101
|-
| 1 
| 4 
| 3 
| 4 
| 4
| 5
|}
 
=== Octal to Binary ===
Simply follow the above procedure in reverse.  Use the memorized table to convert each octal digit to a set of three binary digits.
 
=== Octal to Hexadecimal (and vice versa) ===
This requires slightly more work.  Convert the number in the source base to binary, and then convert from binary to the target base.


== Exercises ==
== Exercises ==
{{W1011-Exercises}}
{{Exercises|
 
* {{MMMAssignment|M1011-10}}
 
}}
 
 
== References ==
== References ==
* [https://en.wikipedia.org/wiki/Positional_notation Positional Notation] (Wikipedia)  
* [https://en.wikipedia.org/wiki/Positional_notation Positional Notation] (Wikipedia)  
Line 178: Line 24:
ability to convert between representations of numbers in the binary, octal, decimal, and hexadecimal systems;
ability to convert between representations of numbers in the binary, octal, decimal, and hexadecimal systems;
}}
}}
{{#set:Sequenced subpages=Positional Notation;Alternative Bases;Formal Representation;Conversions from Decimal;Customs;Shortcut Conversions}}

Latest revision as of 17:58, 8 January 2022

Within these castle walls be forged Mavens of Computer Science ...
— Merlin, The Coder

Curriculum[edit]

ExercisesIcon.png
 Coder Merlin™  Computer Science Curriculum Data

Unit: Numbers

Experience Name: Number Systems (W1011)

Next Experience: ()

Knowledge and skills:

  • §10.311 Demonstrate proficiency in the use of positional notation to represent and convert between numbers in the binary, octal, decimal, and hexadecimal systems

Topic areas: Positional notation

Classroom time (average): 60 minutes

Study time (average): 180 minutes

Successful completion requires knowledge: understand positional notation

Successful completion requires skills: ability to use positional notation to represent numbers in the binary, octal, decimal, and hexadecimal systems; ability to convert between representations of numbers in the binary, octal, decimal, and hexadecimal systems

Experience[edit]



Exercises[edit]

ExercisesExercisesIcon.png
  •  M1011-10  Complete  Merlin Mission Manager  Mission M1011-10.

References[edit]


Experience Metadata

Experience ID W1011
Next experience ID
Unit Numbers
Knowledge and skills §10.311
Topic areas Positional notation
Classroom time 60 minutes
Study time 3 hours180 minutes <br />
Acquired knowledge understand positional notation
Acquired skill ability to use positional notation to represent numbers in the binary, octal, decimal, and hexadecimal systems
ability to convert between representations of numbers in the binary, octal, decimal, and hexadecimal systems
Additional categories