Changes

Jump to: navigation, search

ULI101 Week 4

229 bytes added, 17:05, 31 August 2017
Converting Hex to Binary
<pre class="example">F x 16^2 = 15 x 16^2 = 15 x 256 = 3840
2 x 16^1 = 2 x 16^1 = 2 x 16 = 32A x 16^0 = 10 x 16^0 = 10 x 1 = 10---------------------------------- Sum of 3840+32+10 = 3882
</pre>
Therefore, <code>F2A</code> in Hexadecimal is <code>3882</code> in decimal. I can understand now how decimal numbers can be stored in the computers as binary numbers, but why are we learning Octal and Hexadecimal numbers? As computers and computer programming languages evolved, octal and hexadecimal numbers were considered “short-hand” a short-cut to represent binary numbers.
* Convert the binary number <code>111110000</code> to an octal number:
<pre class="example">= 1 1 1 1 1 0 0 0 0x 2^2 2^1 2^0 2^2 2^1 2^0 2^2 2^1 2^0i.e. (4) (2) (1) (4) (2) (1) (4) (2) (1)1x4+ 1x2+ 1x1 1X4+ 1x2+ 0x1 0X4+ 0x2+ 0x1= (4+2+1) = 7 (4+2+0) = 6 (0+0+0) = 0
</pre>
Therefore, the binary number 111110000 represents 760 as an octal number. This code can be used to represent directory and file permissions (you will learn how to set permissions soon)
* Convert the binary number <code>111110000</code> to a hexadecimal number:
<pre class="example">= 0 0 0 1 1 1 1 1 0 0 0 0(8) (4) (2) (1) (8) (4) (2) (1) (8) (4) (2) (1)1 15 01 F 0
</pre>
Therefore, the binary number <code>111110000</code> represents <code>1F0</code> as a hexadecimal number.
<blockquote>1 hexadecimal digit is equal to 4 binary digits. Group binary digits into groups of 4 starting from the right. Add leading zeros if last group of digits is less than 4 digits. Convert each group of 4 digits to a hexadecimal digit.
</blockquote>
 
=== Converting Hex to Binary ===
<pre class="example"> 1 F 0
= 1 15 0= (8)(4)(2)(1) (8)(4)(2)(1) (8)(4)(2)(1)= 0 0 0 1 1 1 1 1 0 0 0 0
= 000111110000 = 111110000
</pre>
221
edits

Navigation menu