Difference between revisions of "Number Systems"

From Coder Merlin
 
(25 intermediate revisions by 4 users not shown)
Line 1: Line 1:
== Positional Notation ==
== Curriculum ==
'''Positional notation''' (sometimes called '''place-value notation''') is a method of encoding numbers. It differs from other notations (such as Roman numerals) in that it uses the same symbol for different orders of magnitude depending on its position. For example, consider the number 23. The “3” indicates 3 ''ones'', because it is in the ''ones'' position. The “2”, however, indicates 2 ''tens'', because it is in the ''tens'' position. We know the value of a position by its location within the number. As we move ''left'' in a number, each position is valued at ten times the prior position. It might help if we label each position using power notation. Consider the number 123:
{{MerlinCurriculumData|{{ROOTPAGENAME}}}}
 
== Experience ==
[[File:Positional Notation.png]]
{{MerlinMultipageExperienceSubpages
 
  |Pages=Positional Notation;Alternative Bases;Formal Representation;Conversions to Decimal;Conversions from Decimal;Customs;Shortcut Conversions
The “3” is the right-most, and therefore the lowest-valued position, representing “ones” with a position multiplier of 100 (that is, 10 raised to the zero power, or 1). The “2” is located one position to the left, so we multiply by 10 again giving us a position multiplier of 101 (that is, 10 raised to the first power, or 10). Finally, the “1” is located one position to the left, so we again multiply by 10 giving us a position multiplier of 102 (that is, 10 raised to the second power, or 100). By multiplying each digit by its corresponding position multiplier, we can obtain the value of the entire number:
 
1 * 10<sup>2</sup> + 2 * 10<sup>1</sup> + 3 * 10<sup>0</sup> =<br />
100 + 20 + 3 =<br />
123<br />
 
While we generally understand the mechanics of this process in the decimal system, thinking about how it actually works will enable us to consider other systems.
 
== Number Base ==
The '''radix''' or '''base''' is the number of unique digits, ''including zero'', used to represent numbers in a positional numeral system. The base is normally written as a subscript to the right of the number. For example, the decimal number 123 would formally be written as (123)<sub>10</sub><br />
Note that the parentheses are sometimes not written: 123<sub>10</sub><br />
In the case of decimal (base 10) numbers, the subscripted 10 is often assumed and not written.
 
== Decimal System ==
The decimal system is the system with which we are most familiar. It is a decimal system because it contains ten unique digits:<br />
<pre>
0 1 2 3 4 5 6 7 8 9
</pre>
 
For any (integer) value larger than 9, we’re required to use positional notation. Please keep in mind that “10” is not a digit. Rather, it’s a number consisting of two digits, a “1” in the tens (10<sup>1</sup>) position and a “0” in the ones position (10<sup>0</sup>).
 
== Octal System ==
The octal system uses eight unique digits to represent a number:<br />
<pre>
0 1 2 3 4 5 6 7
</pre>
 
Let’s consider the value of an octal number: 4735<sub>8</sub>
 
What is the ''decimal'' value of this number? We use exactly the same method that we use for knowing the value in any system:
 
{| class="wikitable" style="text-align:right;"
| Digit at position:  || 4 || 7 || 3 || 5
|-
| Position multiplier: || 8<sup>3</sup> || 8<sup>2</sup> || 8<sup>1</sup> || 8<sup>0</sup>
|-
| Position value: || 4 &bull; 8<sup>3</sup> || 7 &bull; 8<sup>2</sup> || 3 &bull; 8<sup>1</sup> || 5 &bull; 8<sup>0</sup>
|-
|                || 2048 || 448 || 24 || 5
|}
 
Note that in this case, the right-most digit is, as always, representative of units (ones), just as in any positional system. However, moving one digit to the left, because we’re now using an octal system, the position indicates the number of eights (not tens). The next position to the left indicates the number of sixty-fours (not hundreds) and the final position indicates the number of 512’s. As before, we multiply each digit by its corresponding position multiplier to obtain the value of the entire number:
 
4 &bull; 8<sup>3</sup> + 7 &bull; 8<sup>2</sup> + 3 &bull; 8<sup>1</sup> + 5 &bull; 8<sup>0</sup> =<br/>
2,048<sub>10</sub> + 448<sub>10</sub> + 24<sub>10</sub> + 5<sub>10</sub> =<br/>
2,525<sub>10</sub>
 
== Hexadecimal System ==
The hexadecimal (six and ten) uses sixteen digits to represent a number:<br />
<pre>
0 1 2 3 4 5 6 7 8 9 A B C D E F
</pre>
 
Note that because we only have ten digits in our familiar decimal system, we use the letters A through F to represent the additional six digits in the hexadecimal system. Remember that these are ''digits'', that is, A represents 10, B represents 11, and so on up to F which represents 15.
 
Let’s consider the value of a hexadecimal number: B59C<sub>16</sub>
 
What is the ''decimal'' value of this number?
 
{| class="wikitable" style="text-align:right;"
| Digit at position:  || B || 5 || 9 || C
|-
| Position multiplier: || 16<sup>3</sup> || 16<sup>2</sup> || 16<sup>1</sup> || 16<sup>0</sup>
|-
| Position value: || B &bull; 16<sup>3</sup> || 5 &bull; 16<sup>2</sup> || 9 &bull; 16<sup>1</sup> || C &bull; 16<sup>0</sup>
|-
|                || 45,056 || 1280 || 144 || 12
|}
 
As always, we multiply each digit by its corresponding position multiplier to obtain the value of the entire number:
 
B &bull; 16<sup>3</sup> + 5 &bull; 16<sup>2</sup> + 9 &bull; 16<sup>1</sup> + C &bull; 16<sup>0</sup> =<br/>
45,056<sub>10</sub> + 1280<sub>10</sub> + 144<sub>10</sub> + 12<sub>10</sub> =<br/>
46,492<sub>10</sub>
 
== Binary System ==
The binary system (two) uses two digits to represent a number:<br/>
<pre>
0 1
</pre>
 
Let’s consider the value of a binary number: 1011 1010<sub>2</sub><br/>
What is the decimal value of this number?
 
{| class="wikitable" style="text-align:right;"
| Digit at position:  || 1 || 0 || 1 || 1 || 1 || 0 || 1 || 0
|-
| Position multiplier: || 2<sup>7</sup> || 2<sup>6</sup> || 2<sup>5</sup> || 2<sup>4</sup> || 2<sup>3</sup> || 2<sup>2</sup> || 2<sup>1</sup> || 2<sup>0</sup>
|-
| Position value: || 1 &bull; 2<sup>7</sup> || 0 &bull; 2<sup>6</sup> || 1 &bull; 2<sup>5</sup> || 1 &bull; 2<sup>4</sup> || 1 &bull; 2<sup>3</sup> || 0 &bull; 2<sup>2</sup> || 1 &bull; 2<sup>1</sup> || 0 &bull; 2<sup>0</sup>
|-
|                || 128 || 0 || 32 || 16 || 8 || 0 || 2 || 0
|}
 
Multiplying each digit by its corresponding position multiplier to obtain the value of the entire number:
 
1 &bull; 2<sup>7</sup> + 0 &bull; 2<sup>6</sup> + 1 &bull; 2<sup>5</sup> + 1 &bull; 2<sup>4</sup> + 1 &bull; 2<sup>3</sup> + 0 &bull; 2<sup>2</sup> + 1 &bull; 2<sup>1</sup> + 0 &bull; 2<sup>0</sup> =<br/>
128<sub>10</sub> + 0<sub>10</sub> + 32<sub>10</sub> + 16<sub>10</sub> + 8<sub>10</sub> + 0<sub>10</sub> + 2<sub>10</sub> + 0<sub>10</sub> =<br/>
186<sub>10</sub>
 
== Formal Representation ==
 
Let x be a string of digits, such that:
<math>x = x_{n}x_{n-1}x_{n-2} \cdots x_{0}</math>
 
Then, the value of <math>x</math> in any particular base, <math>b</math>, is calculated as:
<math>\sum_{i=0}^{n} x_{i} \cdot b^i</math>
 
The rightmost digit, <math>x_{0}</math> is referred to as the '''least significant digit''', or '''LSD'''.  It is ''least significant'' because in terms of the overall value of the entire number, this digit will always have the least impact.  Conversely, the leftmost digit, <math>x_{n}</math> is referred to as the '''most significant digit''', or '''MSD'''.  It is ''most significant'' because in terms of the overall value of the entire number, this digit will always have the most impact.
 
== Converting from Decimal to Another Base ==
To convert a decimal (base 10) number to any other base, we simply repeatedly divide by the base until we have a quotient of zero. Specifically, the dividend starts with the number that we want to convert, the divisor will always be the base. The remainder of each successive operation indicates the digit in the new base first at the right-most position and then moving left. The quotient of each step becomes the dividend of the subsequent step.
 
Let’s first try converting the number 28<sub>10</sub> to octal (base 8):
 
The dividend is the decimal number that we want to convert, in this case 28.
The divisor is the base to which we want to convert, in this case 8.
The remainder indicates each successive digit. We stop the process when the quotient is 0.
 
{| class="wikitable" style="text-align:right;"
! Step !! Dividend !! Divisor !! Quotient !! Remainder
|-
| 1 || 28 || 8 || 3 || 4
|-
| 2 || 3 || 8 || 0 || 3
|}
 
So, 28<sub>10</sub> is 34<sub>8</sub>. (Remember that we read the remainder from bottom to top.)
 
Let’s try converting the number 567<sub>10</sub> to octal:
 
{| class="wikitable" style="text-align:right;"
! Step !! Dividend !! Divisor !! Quotient !! Remainder
|-
| 1 || 567 || 8 || 70 || 7
|-
| 2 || 70 || 8 || 8 || 6
|-
| 3 || 8 || 8 || 1 || 0
|-
| 4 || 1 || 8 || 0 || 1
|}
 
So, 567<sub>10</sub> is 1067<sub>8</sub>.
 
Let’s try converting the number 63,215<sub>10</sub> to hexadecimal:
 
{| class="wikitable" style="text-align:right;"
! Step !! Dividend !! Divisor !! Quotient !! Remainder
|-
| 1 || 63215 || 16 || 3950 || 15
|-
| 2 || 3950 || 16 || 246 || 14
|-
| 3 || 246 || 16 || 15 || 6
|-
| 4 || 15 || 16 || 0 || 15
|}
 
So, 63,215<sub>10</sub> is hexadecimal [15][6][14][15], or more conventionally, F6EF<sub>16</sub>. <br/>
(Remembering that in hexadecimal, we use the digit “F” for 15, “E” for 14, etc.)

 
Finally, let’s convert the number 53410 to binary:
 
{| class="wikitable" style="text-align:right;"
! Step !! Dividend !! Divisor !! Quotient !! Remainder
|-
| 1 || 534 || 2 || 267 || 0
|-
| 2 || 267 || 2 || 133 || 1
|-
| 3 || 133 || 2 || 66 || 1
|-
| 4 || 66 || 2 || 33 || 0
|-
| 5 || 33 || 2 || 16 || 1
|-
| 6 || 16 || 2 || 8 || 0
|-
| 7 || 8 || 2 || 4 || 0
|-
| 8 || 4 || 2 || 2 || 0
|-
| 9 || 2 || 2 || 1 || 0
|-
| 10 || 1 || 2 || 0 || 1
|}
 
So, 534<sub>10</sub> is 10 0001 0110<sub>2</sub>
 
== 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 ==
{{ComingSoon|
* Conversions from/to binary, octal, and hexadecimal
}}
}}


== 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)  
* [https://en.wikipedia.org/wiki/Radix Radix] (Wikipedia)
* [https://en.wikipedia.org/wiki/Radix Radix] (Wikipedia)
{{Experience
|experienceID=W1011
|experienceUnit=Numbers
|knowledgeAndSkills=§10.311
|topicAreas=Positional notation
|classroomTime=60 minutes
|studyTime=3 hours
|acquiredKnowledge=understand positional notation;
|acquiredSkill=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;
}}

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