> EGD u)bjbj 4:u!<011111TVVVVVV$Fzz1111TT1Z6@0zz : Number Systems for Beginners by NeoTifa
~~~~~~~~~~~~~~Index~~~~~~~~~~~~~~~~
Part 1.) Introduction
Part 2.) Binary to Decimal
Part 3.) Decimal to Binary
Part 4.) Binary to Octal
Part 5.) Octal to Binary
Part 6.) Binary to Hexadecimal
Part 7.) Hexadecimal to Binary
~~~~~~~~~~~~~Part 1~~~~~~~~~~~~~~~~~~
[b]Introduction: [/b]
Hi, thanks for reading my tutorial. This is my first non-Java one, so bear with me. I think binary is a very important concept when it comes to computer programming, and yet a lot of people do not know anything about binary. Therefore, Im going to sit down and bust this out for your benefit. Just kidding, this is helping me study for my Digital Circuits exam! ;)
A computer is a system of wires and logic gates that computes anything. It can be as complex as the Dell or Apple computer on your desk, or as simple as a pocket calculator. Its a compute-er, get it? Back in the day, the wrinkly old scientists needed some quicker way to compute complex equations for their [s]evil[/s] science, so they used science to discover that electricity can be manipulated logically to form equations. Unfortunately, youll notice that your light switch can only have 2 different [i]states[/i]: on and off. This is the same limitation said crusty old guys found, so they use gates to manipulate the current to do their [s]evil[/s] bidding.
As for the logic, I might do another tutorial on that later, but for the purpose of this tutorial, were going to focus on those 2 states: on and off. Since a computer is just an assembly of electrical components, like your light switch, there are really only 2 states that the computer can register: on and off. There are also other ways to represent it: high/low, 1/0, on/off, true/false, etc. Humans took the 1/0 representation and ran with it. We call it [i]binary[/i]. Any number can be represented as a series of 1s and 0s, and Im going to show you how!
[i]Fry! I had the most horrible nightmare! 1s and 0s everywhere! I think I even saw a 2! -Bender[/i]
~~~~~~~~~~~~~~~~~Part 2~~~~~~~~~~~~~~~~~~
[b]Binary to Decimal: [/b]
[u]Decimal:[/u] The number system we puny humans are most familiar with.
Base: 10
Coefficients: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
Weight: Power of 10
Notation: (10573406)[sub]10[/sub]
[u]Binary:[/u] Series of 1s and 0s that a computer is most familiar
Base: 2
Coefficients: 0, 1
Weight: Power of 2
Notation: (10100101101)[sub]2[/sub]
A binary number can be small or large, and can even have decimal points! Each one or zero is called a [i]bit[/i]. When someone says their system is a 64-bit system, it means it can process calculations with sequences containing 64 different 1s and 0s. The number 7, or 111, has 3 bits; the number 3, 11, has 2 bits. Every place in the string of 1s and 0s is 2 to the nth power, with n being the index. All you need to find the decimal equivalent is to take the ones and add them. Just start at the right-most bit (to the left of the decimal point if applicable), which is also called the [i]least significant bit[/i], and add starting with 2^0.
bit(n)*2^(n) + bit(n-1)*2^(n-1) + bit(n-2)*2^(n-2) + ... + bit(2)*2^(2) + bit(1)*2^(1) + bit(0)*2^(0) = Decimal Integer
Here are some examples:
0 = 0
1 = 1
11 = 2^1 + 2^0 = 2 + 1 = [b]3[/b]
111 = 2^2 + 2^1 + 2^0 = 4 + 2 + 1 = [b]7[/b]
10101 = 2^4 + 2^2 + 2^0 = 16 + 4 + 1 = [b]21[/b]
Notice how I skipped 2^3 and 2^1 above? This is because there are 0s in those places, and because the coefficient would be zero, resulting in 0*2 = 0, its unnecessary to compute that. It would be useful to know the powers of 2 off hand, but its not necessary.
1024 = 2^10
512 = 2^9
256 = 2^8
128 = 2^7
64 = 2^6
32 = 2^5
16 = 2^4
8 = 2^3
4 = 2^2
2 = 2^1
1 = 2^0
Now for decimal points, you add fractions, or 2 to negative exponents.
... 2^(2) + 2^(1) + 2^(0) + 2^(-1) + 2^(-2)....
Really, youre just moving across the number line! (Make sure youre starting at zero right at the decimal point though!)
1.1 = 1.5
1.11 = 1.75
etc.
~~~~~~~~~~~~~~~Part 3~~~~~~~~~~~~~~~
[b]Decimal to Binary: [/b]
Going backwards is fairly easy as well. In fact, there are 2 main ways to do it.
[u]1st Method:[/u]
If you know the 2s powers, just subtract the largest possible one that is smaller than or equal to the number youre trying to convert. This will be your first place for a one. If the 2s power below it cant be subtracted (i.e. its larger than) the difference, than a zero will go into that place. Just repeat until youve reached zero!
500: 500 256 = 244 therefore 2^8 = 1
244 128 = 116 therefore 2^7 = 1
116 64 = 52 therefore 2^6 = 1
52 32 = 20 therefore 2^5 = 1
20 16 = 4 therefore 2^4 = 1
4 4 = 0, therefore 2^3 = 0, 2^2 = 1, 2^1 = 0, and 2^0 = 0, giving us 111110100.
Easy, no?
[u]2nd Method: [/u]
This ones just as easy. Just divide by 2 until you reach 0, and the remainder is the binary bit value. [b]This method give the binary started at the least significant bit!!![/b]
500:
500 / 2 = 250 ([b]r: 0[/b])
250 / 2 = 125 ([b]r: 0[/b])
125 / 2 = 62 ([b]r: 1[/b])
62 / 2 = 31 ([b]r: 0[/b])
31 / 2 = 15 ([b]r: 1[/b])
15 / 2 = 7 ([b]r: 1[/b])
7 / 2 = 3 ([b]r: 1[/b])
3 / 2 = 1 ([b]r: 1[/b])
1 / 2 = 0 ([b]r: 1[/b]) ... thus giving us 111110100.
~~~~~~~~~~~~~Part 4~~~~~~~~~~~~
[b]Binary to Octal: [/b]
[u]Octal: [/u] A human system that counts in 8s. Why? Idk.
Base: 8
Coefficients: 0, 1, 2, 3, 4, 5, 6, 7
Weight: Power of 8
Notation: (35157351)[sub]8[/sub]
Octal is kind of a mix between binary and decimal, sort of easy for humans, but it reads in 8^n + 8^n-1 etc. The max number in each place can be 7, which is 111. Therefore, every 3 bits is an octal number. To convert from binary to octal, just start from the decimal point, and group outwards every 3 bits. If there is a leftover, or the number of bits isnt divisible by 3, just pad it with 0s until it is 3 bits. The reason why it cant be 8 (1000) is because 8 is 4 bits, and then you would just pad it with 0s, turning 1000 into 10 in octal.
For instance 11111.1, you would divide and pad them as such: 011 111.100. This is generally why there are spaces in binary numbers, as sometimes the coder spaces them for you. ;) Each grouping is then converted into its appropriate octal number. Also, instead of adding fractions, just convert it as if it were just a regular number to the left of the decimal.
011 = 3, 111 = 7, 100 = 4
Therefore, (11111.1)[sub]2[/sub] = (37.4)[sub]8[/sub]
~~~~~~~~~~~~Part 5~~~~~~~~~~~~
[b]Octal to Binary: [/b]
Super easy! Just take each index, or place, and convert it into a [padded if necessary] 3 bit number! Taking the padding back out from the ends is optional.
Ex.
2534 = 010 101 011 100
435.5 = 100 011 101.101
In fact, when I do binary stuff, I like to remember the truth tables I did in math.
[code]
ABC 3-bits
---------------------------
000 - 0
001 - 1
010 - 2
011 - 3
100 - 4
101 - 5
110 - 6
111 - 7
[/code]
See, theres a pattern, so if you keep this in your mental database you can remember them easier. ;)
~~~~~~~~~~~~~~~~Part 6~~~~~~~~~~~~~~~~
[b]Binary to Hexadecimal: [/b]
[u]Hexadecimal:[/u] Another human system, popular with the visual kiddies and stuff
Base: 16
Coefficients: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F
Weight: 16
Notation: (32AD635)[sub]16[/sub]
This one scares people for some reason. They see letters in a number system and freak... or I did at least. Haha, its not that hard though. Because 0 and 1 are their own separate numbers, you have to notate 10 15 in some other way, so we just use letters. To convert to hex, you do the same thing as octal, but instead of 3 bits its 4. Simple enough.
Ex.
10110101011010100.010100111 =
0001 0110 1010 1101 0100.0101 0011 1000 =
1 6 A D 4.5 3 8 =
16AD4.538
[code]
ABCD 4 bits
---------------------------------
0000 0
0001 1
0010 2
0011 3
0100 4
0101 5
0110 6
0111 - 7
1000 8
1001 9
1010 A
1011 B
1100 C
1101 D
1110 E
1111 F
[/code]
~~~~~~~~~~~~~~~Part 7~~~~~~~~~~~~
[b]Hexadecimal to Binary: [/b]
Just like with octal, take each character and convert it to its respective [potentially padded] 4-bit binary number, then take out the padding on both ends [if you added it].
Ex.
3986 =
0011 1001 1000 0110 =
111001100000110
132AD.7 =
0001 0011 0010 1010 1101.0111 =
10011001010101101.0111
In order to convert between different number systems, just use binary as the middle man. So to get from Oct to Hex, just go Oct -> Bin -> Hex. Well, this concludes my tutorial. Hope someone finds it useful. Thanks for reading! ^__^
()t)u)hlNh%^h\CJOJQJaJhlNhlNCJOJQJaJ()MNd 2 H I
R
S
78gdlN3;Na,-56BLV`ir{gdlN>?R.LgdlNpu/G}~"5VW|} !8!9!X!q!gdlNq!r!""","E"F"""""""""""###x#y####$$Z$e$gdlNe$$$%%%&8&K&U&V&]&k&&&&&&&&&&&&&&''''gdlN'%'&'H'g'h'(("(8(H(I(T(u(((u)gdlN21h:p!/ =!"#$%j666666666vvvvvvvvv666666>6666666666666666666666666666666666666666666666666hH6666666666666666666666666666666666666666666666666666666666666666662 0@P`p2( 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p 0@P`p8XV~ OJPJQJ_HmH nH sH tH J`J!NormaldCJ_HaJmH sH tH DA D
Default Paragraph FontRiR0Table Normal4
l4a(k (
0No ListPK![Content_Types].xmlj0Eжr(Iw},-j4 wP-t#bΙ{UTU^hd}㨫)*1P' ^W0)T9<l#$yi};~@(Hu*Dנz/0ǰ$X3aZ,D0j~3߶b~i>3\`?/[G\!-Rk.sԻ..a濭?PK!֧6_rels/.relsj0}Q%v/C/}(h"O
= C?hv=Ʌ%[xp{۵_Pѣ<1H0ORBdJE4b$q_6LR7`0̞O,En7Lib/SeеPK!kytheme/theme/themeManager.xmlM
@}w7c(EbˮCAǠҟ7՛K
Y,
e.|,H,lxɴIsQ}#Ր ֵ+!,^$j=GW)E+&
8PK!Ptheme/theme/theme1.xmlYOo6w toc'vuر-MniP@I}úama[إ4:lЯGRX^6؊>$!)O^rC$y@/yH*)UDb`}"qۋJחX^)I`nEp)liV[]1M<OP6r=zgbIguSebORD۫qu gZo~ٺlAplxpT0+[}`jzAV2Fi@qv֬5\|ʜ̭NleXdsjcs7f
W+Ն7`gȘJj|h(KD-
dXiJ؇(x$(:;˹!I_TS1?E??ZBΪmU/?~xY'y5g&/ɋ>GMGeD3Vq%'#q$8K)fw9:ĵ
x}rxwr:\TZaG*y8IjbRc|XŻǿI
u3KGnD1NIBs
RuK>V.EL+M2#'fi~Vvl{u8zH
*:(W☕
~JTe\O*tHGHY}KNP*ݾ˦TѼ9/#A7qZ$*c?qUnwN%Oi4=3ڗP
1Pm\\9Mؓ2aD];Yt\[x]}Wr|]g-
eW
)6-rCSj
id DЇAΜIqbJ#x꺃6k#ASh&ʌt(Q%p%m&]caSl=X\P1Mh9MVdDAaVB[݈fJíP|8քAV^f
Hn-"d>znǊ ة>b&2vKyϼD:,AGm\nziÙ.uχYC6OMf3or$5NHT[XF64T,ќM0E)`#5XY`פ;%1U٥m;R>QDDcpU'&LE/pm%]8firS4d7y\`JnίIR3U~7+#mqBiDi*L69mY&iHE=(K&N!V.KeLDĕ{D vEꦚdeNƟe(MN9ߜR6&3(a/DUz<{ˊYȳV)9Z[4^n5!J?Q3eBoCMm<.vpIYfZY_p[=al-Y}Nc͙ŋ4vfavl'SA8|*u{-ߟ0%M07%<ҍPK!
ѐ'theme/theme/_rels/themeManager.xml.relsM
0wooӺ&݈Э5
6?$Q
,.aic21h:qm@RN;d`o7gK(M&$R(.1r'JЊT8V"AȻHu}|$b{P8g/]QAsم(#L[PK-![Content_Types].xmlPK-!֧6+_rels/.relsPK-!kytheme/theme/themeManager.xmlPK-!Ptheme/theme/theme1.xmlPK-!
ѐ' theme/theme/_rels/themeManager.xml.relsPK]
u!:u)q!e$'u)8@0(
B
S ? 'uw )* !!w!NVdl?D!(BDw y $
'
@BHJwyW[ !w!3333333333333333333333333333333333333t!w!eF
[
v;!YY$w&i5(|?TIV4tZ%^xl{+xm*|\ws]s$joZ'}FlN^;u!w!@!!!!u!`@UnknownG*Ax Times New Roman5Symbol3.*Cx Arial7.{ @CalibriA BCambria Math"qhCFCFw <w <!20d!d!2HX $Pws2!xxBoyerEABoyerEAOh+'0
px
BoyerEANormalBoyerEA2Microsoft Office Word@Ik@06@06 w՜.+,0hp
U.S. Air Force<d!Title
!"#$%'()*+,-./012356789:;=>?@ABCFRoot Entry F
6HData
1Table&WordDocument4:SummaryInformation(4DocumentSummaryInformation8<CompObjy
F'Microsoft Office Word 97-2003 Document
MSWordDocWord.Document.89q