Shadow Blade
Morrowland Presents Apron Tutorials
game - design - multimedia - web - programming - tutorials - There are currently viewers visiting Apron Tutorials.
   
 
TECHNICAL
GRAPHICAL
SOUND
GAME
WEB
ARTICLE
TOOL
PROJECT
 
 NEWS

  news

  history


 TECHNICAL TUTORIALS

  opengl

  direct3d

  c/c++

  visual basic

  java

  c#


 WEB TUTORIALS

  html

  dhtml

  asp

  php


 IMAGE EDITING

  photoshop

  draw sketch


 3D MODELING

  3d studio


 PROJECTS

  shadow blade

  game environment

  virtual 3d guide

  billy blue flame


 DEMOS

  win32 api


 ARTICLES

  general

  opengl


 COMMUNITY

  about us

  credit

  contact






Decimal, Binary and Hexadecimal

Let's learn to count...

But before you go on you can look at this BINARY, HEX, DECIMAL CONVERTER TOOL!

Decimal number system:
Before we start with the new stuff we will take a look at the number system which we all know the decimal number system. Starting with something we already know will make it easier to introduce the concepts we will use in the other numbering systems. We have ten digits, 0 to 9. This is what we call a base 10 number system (radix of 10). It is really arbitrary that we wound up using a base 10 number system, but it probably has something to do with the fact that we have 10 fingers.

Start counting: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, and you will find that there are no more digits left. How do we continue counting when we only have 10 digits? We add a second column of digits, worth ten times the value of the first column. Start counting again: 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20 (Note that the right column goes back to zero here!), 21, 22, 23, ... , 94, 95, 96, 97, 98, 99, and once again, there are no more digits left. The only way to continue counting is to add yet another column worth ten times as much as the one before. Continue counting: 100, 101, 102, ... 997, 998, 999, 1000, 1001, 1002, etc.
Another way to look at the numbers is to write decimal numbers in expanded notation. 365 = 3×100 + 6×10 + 5×1. 1032 = 1×1000 + 0×100 + 3×10 + 2×1. By writing numbers in this form, the value of each column becomes “clearer”.

Binary number system:
Now let us take a look at the binary base 2 number system (radix of 2). The binary number system works in the exact same way as the decimal system, except that it contains only two digits, 0 and 1. Start counting in binary: 0, 1, and you will need a system to keep on counting. In order to keep counting, we need to add a second column worth twice the value of the column before. We continue counting again: 10, 11, and it is time to add another column again. Counting further: 100, 101, 110, 111, 1000, 1001, 1010, 1011, 1100, 1101, 1110, 1111.... Watch the pattern of 1's and 0's. You will see that binary works the same way decimal does, but with fewer digits.

Binary:Decimal:
00000
00011
00102
00113
01004
01015
01106
01117
10008
10019
101010
101111
110012
110113
111014
111115
 
Binary:Decimal:
0001 000016
......
0001 111131
0100 000032
......
0011 111163
0100 000064
......
0111 1111127
1000 0000128
......
1111 1111255

Convert from Binary to Decimal:
Converting a binary number into decimal is easy once you get the hang of it.

Step1: Write down the binary number you want to convert, in this case 1111 1111.
Binary 8 Digit Number: 11111111

Step.2: Count your binary digits right to left starting at zero. Since we have 8 binary digits this means 0 to 7.
Column Number: 76543210

Step.3: Use the number 2 (binary) as base, and the column number (counted above) as exponent 2^n. Using the power of 2 we will double the value for each column.
Calculate Decimal Column Value: 2^72^62^52^42^32^22^12^0

Step.4: It's time to calculate the values from above. You might recognize these values 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, etc..
Sum Decimal Column Value: 1286432168421

Step.5: Add the numbers and the sum will be the valid decimal number 255.
Decimal Sum: 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255

Thats it!


Concider the decimal number 255 = 1111 1111 in the table below:
Binary 8 Digit Number: 11111111
Column Number: 76543210
Calculate Decimal Column Value: 2^72^62^52^42^32^22^12^0
Sum Decimal Column Value: 1286432168421
Decimal Sum: 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255
Alternative Sum: 2^7 + 2^6 + 2^5 + 2^4 + 2^3 + 2^2 + 2^1 + 2^0 = 255

Concider the decimal number 169 = 1010 1001 in the table below:
Binary 8 Digit Number: 10101001
Column Number: 76543210
Calculate Decimal Column Value: 2^7-2^5-2^3--2^0
Sum Decimal Column Value: 12803208001
Decimal Sum: 128 + 0 + 32 + 0 + 8 + 0 + 0 + 1 = 169
Alternative Sum: 2^7 + 2^5 + 2^3 + 2^0 = 169


Hexadecimal number system:
Because the binary number system is simple it can be used in advanced digital electronics. It is inefficient for humans to use binary, however, because it requires so many digits to represent a number. The number 76, for example, takes only two digits to write in decimal, yet takes seven digits to write in binary (1001100). To overcome this limitation, the hexadecimal number system was developed. Hexadecimal is more compact than binary but is still based on the digital nature of computers. Hexadecimal works in the same way as binary and decimal, but it uses sixteen digits instead of 2 or 10. Since the western alphabet contains only ten digits, hexadecimal uses the letters A-F to represent the digits ten through fifteen. We have 16 digits, 0 to F. This is what we call a base 16 number system (radix of 16). We count like this: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F.

Binary:Decimal:HEX:
000000
000111
001022
001133
010044
010155
011066
011177
100088
100199
101010A
101111B
110012C
110113D
111014E
111115F
 
Binary:Decimal:HEX:
0001 00001610
.........
0001 1111311F
0100 00003220
.........
0011 1111633F
0100 00006440
.........
0111 11111277F
1000 000012880
.........
1111 1111255FF

Let's count in hexadecimal. Starting from zero, we count 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F. At this point there are no more digits, so we add another column. Continue counting: 10, 11, 12, 13, 14, 15, 16, 17 18, 19, 1A, 1B, 1C, 1D, 1E, 1F. Once again, we are out of digits in the first column, so we add one to the next column. Continue counting once again: 20, 21, 22, ..., 29, 2A, 2B, 2D, 2E, 2F, 30, 31, 32, ..., 3E, 3F, 40, 41, 42, ... 99, 9A, 9B, 9C, 9D, 9E, 9F, A0, A1, A2, ... F9, FA, FB, FC, FD, FE, FF, 100, 101, 102, .... Watch the pattern of numbers and try to relate this to the way you count in decimal or binary. You will see that it is the same procedure, but with sixteen digits instead of 10 or 2.

Each column in hexadecimal is worth 16 times the column before, while each column in binary is worth 2 times the column before. Since 2×2×2×2=16, this means that each hexadecimal digit is worth exactly 4 binary digits. This fact makes it easy to convert between binary and hexadecimal.

Convert from HEX to Binary:
To convert from hexadecimal to binary, simply look at the chart above and replace each digit in the hexadecimal number with its corresponding four-digit binary number. For example, 8F in hexadecimal is 10001111 in binary, since 8=1000 and F=1111.

Convert from Binary to HEX:
To converty from binary to hexadecimal, reverse the procedure above and break the binary number into blocks of four digits. Then, replace each block of four digits with its corresponding hexadecimal digit. If you cannot divide the binary number evenly into blocks of four digits, add zeros to the left side of the number to make it work. For example, to convert 110101 to hexadecimal, first add two zeros at the beginning of the number to make it 00110101. Since 00110101 has eight digits, it can be divided into two blocks of four digits, 0011 and 0101. Since 0011=3 and 0101=5, the corresponding hexadecimal number is 35.

CLICK HERE TO GO TO BINARY, HEX, DECIMAL CONVERTER TOOL!


 LINKS

  morrowland home



 GAME DEVELOPEMENT

  nvidia

  gamedev

  polycount


 PROJECTS

  shadow blade

  game environment

  virtual 3d guide

  billy blue flame


 MATH AND PHYSICS

  mathworld

  physicsworld







PLEASE LINK TO


  All rights reserved Morrowland © 2017  
Ronny André Reierstad