Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[TUT] Understanding Computer Numeric Systems
Understanding Computer Numeric Systems

The only thing you will need for this tutorial is a bit of thought. You will not need any programs, although you may want to grab a calculator or do the math work in your head. I'll give points where you can do a bit of thinking/explaining to yourself so that you can make sure you understand the work. These will be provided at appropriate points in the tutorial.

Whenever you write a program you will be using a programming language, whether it is Java, C++, Python, you will be using a programming language. The languages you use are made up of 'characters' or symbols. In everyday language these characters/symbols would be called letters or signs (full stop, comma's, question marks, signs, etc), but for computer talk we will refer to them as characters.

In almost all cases, the computer would see these characters as jumbled up jargon, no matter how you put them in. Well constructed sentences still mean nothing to the computer if it is trying to run them directly. For the computer to understand what you're trying to tell it to do the characters are converted into numbers for various numeric systems.

This is where this tutorial is going to come into play. I'm going to teach you a few different numeric systems that the computer uses (decimal, binary and hexadecimal). Let it be known whether you deliberately use them or not in your work, the computer still uses and reads them. The latter two will be the most use to you in terms of modifying Little Fighter 2.

The Decimal numeric system is the most familiar one to you. This is because you use it in every day life. It makes use of these 10 symbols:

Decimal Symbols Wrote:0, 1, 2, 3, 4, 5, 6, 7, 8, 9

Each symbol is known as a digit. Multiple digits are capable of being combined in various different ways to produce all sorts of numbers imaginable.

It is called Decimal as it is based on 10 digits (Dec- in Decimal means 10). Although it is common knowledge how to use the Decimal system I am going to show you anyway, purely for the sake of conversions and later ease through the tutorial.

So here is I would like you to represent your numbers, given a few as examples (Note * means to multiply by):

Decimal Examples Wrote:0 = 0 * 100
1 = 1 * 100
2 = 2 * 100
10 = 1 * 101 + 0 * 100
20 = 2 * 101 + 0 * 100
24 = 2 * 101 + 4 * 100
371 = 3 * 102 + 7 * 101 + 1 * 100
632 = 6 * 102 + 3 * 101 + 2 * 100

Now hopefully you've understood those fairly well by looking at the pattern. So I'm going to give some rough explanation. Anything to the power of 0 (0) = 1. You will always use 100 on the furthest right digit. From the furthest right digit, you will count every digit to the left of it, to find what number to use to the power of. I'm going to use 2835561, 38471, 17 and 9643 as examples here to show you how its done:

Examples Wrote:l 6 l 5 l 4 l 3 l 2 l 1 l 0 l

l 2 l 8 l 3 l 5 l 5 l 6 l 1 l
l 0 l 0 l 3 l 8 l 4 l 7 l 1 l
l 0 l 0 l 0 l 9 l 6 l 4 l 3 l
l 0 l 0 l 0 l 0 l 0 l 1 l 7 l

Now you can see how they all line up perfectly. The numbers at the top are your positions or powers for each digit. Thats how you are going to allocate the correct powers when using the equations.

From the mock table you have also noticed that I put 0's in the entries where no other digit would take it up, but why don't we do that when we write down numbers? It is actually to save time, hassle and in this case confusion. You should not write any 0's infront of your numbers for future reference.

A faster and possibly more efficient way to find the powers is to do the "n-1" rule. n in this rule is how many digits from the right your digit is at. You then subtract (-) 1 from this to get the power that you will be using. Here's an example, where we'll find the power for the digit 3 in 28367:

n-1 rule Wrote:28367 l
3 is 3rd along from the line to the right aka n = 3.
n-1 rule is used.
3 - 1 = 2
So we do 3 * 102

You start your counting from the line (visible or invisible - however you decide to do it) and go left. Simple right? You should use whichever you find easier out of the table and the "n-1" rule. Soon enough you will be able to do it in your head without even thinking about either of the rules, you'll just know it off by heart. These two methods are just stepping stones to get you on your way.

1) Split apart the numbers 84536, 487 and 14 into their seperate equations.
2) Find what power of 10 the 4's are in 84536, 487 and 14 using "n-1" rule.
3) Find what power of 10 the 2's are in 934218, 87326 and 2918345 using the table rule.

The most fundamental of computer or machine languages is the Binary system. It is known as the Binary system because it utilises a base 2 system (bi- in Binary means 2).

When a computer deals with a piece of information, it considers it either true or false. If it is considered true then it is given a value of 1, if it is considered false then it is given a value of 0. Hence there are only two symbols in this case that the computer will respond to.

Now we're going to learn to count in Binary. I'm assuming that when you first read something like 101000111110110010101 you do not have a clue what it's saying. In fact it probably just looks like a bunch of 1's and 0's with no logical pattern, which you may mispronounce and use the Decimal system of counting.

First of all I'll show you how to represent numbers:

Binary Representation Wrote:0 = 0 * 20
1 = 1 * 20
10 = 1 * 21 + 0 * 20
11 = 1 * 21 + 1 * 20
100 = 1 * 22 + 0 * 21 + 0 * 20

As you can see it is much the same as representing in Decimals however instead of using the base 10 you will use the base 2.

Now that you've shown how you can represent the numbers, that means you can count or convert the Binary into Decimal. So here are some examples where we convert 101, 11 and 101010010 from Binary to Decimal:

Binary To Decimal Wrote:11 = 1 * 21 (1 * 2) + 1 * 20 (1 * 1) = 3
101 = 1 * 22 (1 * 4) + 0 * 21 (0 * 2) + 1 * 20 (1 * 1) = 5
101010010 = 1 * 28 (1 * 256) + 0 * 27 (0 * 128) + 1 * 26 (1 * 64) + 0 * 25 (0 * 32) + 1 * 24 (1 * 16) + 0 * 23 (0 * 8) + 0 * 22 (0 * 4) + 1 * 21 (1 * 2) + 0 * 20 (0 * 1) = 338

As you can also see, the way that you find powers is the same as that done in Decimals. So if you need your memory refreshed on how to find the powers - go back to the Decimal section to do so, looking at the table method and "n-1" rule.

Keep refreshing your mind on Binary and Decimal as you move on through this tutorial, they're going to become important as we progress, especially Binary.

1) Split apart the following Binary numbers; 1011, 1011010, 101
2) Convert the following from Binary to Decimal; 1011, 1011010, 101
3) Convert the follow from Decimal to Binary; 6, 132, 24

Hexadecimal is the most important numeric system to you in terms of Little Fighter 2. This is because you will need it for when you are Hex or .exe editing the Little Fighter 2 program. So pay close attention to this section when you are reading through this tutorial.

Hexadecimal makes use of a base 16 system. However all latin languages only make use of 10 digits (0 to 9). To get around this problem, Hexadecimal makes use of the first 6 letters of the alphabet to represent their numbers (A-F). To make this slightly easier on you right now I'm going to convert Hexadecimal to Decimal for the first 16 numbers:

Hexadecimal to Decimal Wrote:0 = 0
1 = 1
2 = 2
3 = 3
4 = 4
5 = 5
6 = 6
7 = 7
8 = 8
9 = 9
A = 10
B = 11
C = 12
D = 13
E = 14
F = 15

Now we know the conversions of the base digits from Hexadecimal into Decimal, we're going to start representing some numbers in their split up form. So here are some examples:

Examples Wrote:9 = 9 * 160
C = 12 * 160 = 12
3F = 3 * 161 (3 * 16) + 15 * 160 (15 * 1) = 63
1A1 = 1 * 162 (1 * 256) + 10 * 161 (10 * 16) + 1 * 160 (1 * 1) = 417
FF = 15 * 161 (15 * 16) + 15 * 160 (15 * 1) = 255

As you can see, base 16 is used instead of base 10. Once again the powers are worked out through the use of either the table method or the "n-1" rule. Go back to the Decimal section to refresh your mind on these methods.

Now to stop any confusion between Hexadecimal and Decimal numbers, when you write then down in pseudo-form (aka not in a Hex editor) you are going to put 0x infront of the number, like so:

0x2F3A, 0x345492, 0xF12

As some of you may notice, this is how you would represent them in C# or C++ (the language that the Little Fighter program was created in).

1) Split apart the following Hexadecimal numbers: 1F, 63C, A7C8
2) Convert the following from Hexadecimal to Decimal: 1F, 63C, A7C8
3) Convert the follow from Decimal to Hexadecimal: 19, 342, 92, 2435

This is just going to be a quick section showing the conversions of several numbers from Binary to Decimal to Hexadecimal, in that order. I will then ask you to do a few more questions to convert some more yourselves.

Conversions Table Wrote:0 = 0 = 0
1 = 1 = 1
10 = 2 = 2
11 = 3 = 3
100 = 4 = 4
101 = 5 = 5
110 = 6 = 6
111 = 7 = 7
1000 = 8 = 8
1001 = 9 = 9
1010 = 10 = A
1011 = 11 = B
1100 = 12 = C
1101 = 13 = D
1110 = 14 = E
1111 = 15 = F
10000 = 16 = 10
10001 = 17 = 11
10010 = 18 = 12
10011 = 19 = 13
10100 = 20 = 14
10101 = 21 = 15
10110 = 22 = 16
10111 = 23 = 17
11000 = 24 = 18
11001 = 25 = 19
11010 = 26 = 1A
11011 = 27 = 1B
11100 = 28 = 1C
11101 = 29 = 1D
11110 = 30 = 1E
11111 = 31 = 1F

Those are the first 32 numbers written in Binary, Decimal and Hexadecimal. This is just to give you a head start for when you progress later on, a bit of a taster should we say.

1) Convert the following from Hexadecimal to Decimal; 48, F1F, AC
2) Convert the following from Decimal to Hexadecimal; 103, 8263, 72
3)Convert the following from Binary to Decimal; 1100010, 11101011, 1000001101101
4) Convert the following from Decimal to Binary; 82, 356, 93
5) Convert the following from Binary to Hexadecimal; 1100010, 11101011, 1000001101101
6) Convert the following from Hexadecimal into Binary; 48, F1F, AC

Computers use Binary to represent their information, utilising only 1's and 0's. These numbers are otherwise known as Digits, as you would find in the Decimal and Hexadecimal system. These Binary Digits are abbreviated to Bit (Binary Digit). As said before they are the most fundamental representation of a machine or computers counting system.

Bits can only store extremely tiny amounts of information. This means that for your computer to hold any decent or relevant information, the Bits would need to be combined. So I bring you to the Four-Bit Combination Model, which is more effective for the computer to use.

You treat this as you would Binary when working out the combinations, as each of the four sections on the Four-Bit Combination Model can only store either a 1 or a 0. We will count each bit the same way that we counted each digit in Decimal, the "n-1" rule helps out here, once again starting from right and going left.

The first or 0 bit on the right hand side of the Four-Bit Combination Model is known as the Low Order (LO) Bit. It is also the least significant Bit. The last or 3 bit, located on the left hand side of the Four-Bit Combination Model is known as the High Order (HO) Bit. It is known as the most significant Bit. However, you will not need to go into this for now, it's just for the purpose of knowledge.

The Four-Bit Combination Model allows for a variety of different combinations, because of the various placements of 0 or 1 that you can have on each bit. In fact, these are the exact combinations that you could have:

Bit Combinations Wrote:0000

That just so happens to be 16 combinations. Now, why is this relevant to you? These 16 combinations just so happen to be equal to the number of Digits you use in Hexadecimal. Each combination is equal to one specific Digit in Hexadecimal.

This is why a computer is able to read Hexadecimal. It is far less confusing for the person controlling the computer to write in Hexadecimal as the numbers are not extremely long and the computer can easily convert any Hexadecimal Digit or number into Binary in no time at all.

1) What is a bit?
2) Why is the Four-Bit Combination Model useful to you?

Bytes are actually groups of 8 consecutive bits. The Bits in a Byte are counted in the same way you would the Four-Bit Combination Model and also make use of the HO (High Order) and LO (Low Order) Bits, once again something you don't need to know much about.

Just as you would in the Four-Bit Combination Model, you can use varying different combinations of 1's and 0's to count in a Byte. The lowest value of which is 00000000 and the highest value would be 11111111.

I am not going to show you all the different combinations of Bits within a Byte, purely because that would take a long time and I would lose my patience. Instead I am going to tell you how many different combinations you can get and how you can work it out.

Byte Combinations Wrote:Using the Base 2 rule:
27 + 26 + 25 + 24 + 23 + 22 + 21 + 20 =
128 + 64 + 32 + 16 + 8 + 4 + 2 + 1
= 255

Now, the last Bit can also have a 0 and not just a 1, so we will add 1 more combination to it.

255 + 1 = 256

Now once again I'm going to ask you, why on earth is this important to you? The amount of information stored by a Byte is capable of storing a single character (A, B, C, D..., 1, 2, 3... ?, >, <.... etc) that you may use on your keyboard.
The characters are organised by something all coders or Hexers may have heard of or seen before; ASCII. This stands for the American Standard Code for Information Exchange (Don't ask by the way, I don't know why there is an I instead of an E... it is just there).
ASCII uses only 128 Decimal numbers (7 Bit) to represent symbols or characters counted from 0-127. Which brings you to another question... why on earth would you need to use a Byte or 8 bit combination? Answer; It's the minimum storage area offered by the computer (Intel). So what happens to the last bit? It's used for accents, mathematical symbols, small graphics.. etc.

Okay so why is this important to you? Sure a Byte can hold the ASCII that you need, but how does that really help with Hex Editing? Well, if by now you hadn't noticed or tested for 2 digits in Hexadecimal, the maximum number produced is 255 in Decimal (0xFF).

Now if you look at a true Hex Editor like Hex Workshop or OllyDbg you will notice that you get lots of 2 digit combinations of Hex in the Hex area. Thats because a Hex Editor is used to view every single byte that a program has. So of course, the Byte is very important for you to know about, purely for the sake of knowing about it and understanding what you're doing a little better.

1) What is the maximum number in Decimal that can be stored in a Byte?
2) How many Bits is a Byte made out of?
3) How many combinations of Bits in a Byte can you get?
4) What does ASCII stand for?
5) Why is a Byte useful to you?

Okay, I'm glad to see you stuck with this tutorial till the end, I hope it helps. Remember there will be a lot more tutorials to come from me, this is simply the basics for you to get your head around. Some of you this may have helped, some of you it may not have, some it may have just done an overall recap of something you already knew.

Now, as for the answers to the questions I will post them up soon. For now if you definately need them, try to google them as I'm sure most of them will be on there.

If anyone would like to know any more on a certain topic or section of this tutorial, feel free to leave a message on exactly what it is you'd like to learn more about. I'll then try my best to make a more in depth guide for it.

Next Tutorial will be:
Learning your way around Hex Editors -
I will be using a variety of different Hex Editors and programs, and displaying with pictures what you need to know to find your way around them and to find code.

Future Tutorials:
I will be writing small programs which I will then put for download. These programs can then be looked at in the Hex Editors by you. I will then explain how you can convert some of the Hex you see into pseudo code.
I will also explain certain commands and stuff you find in Hex Editors.
Later I will bring in specific Little Fighter related stuff - possibly going into detail about PLATFORMS, new ITR's and generally recovering the work that Silva did, explaining it a bit more idiot friendly though..

That's all for now guys, feel free to leave thanks please - would be much appreciated since I've spent since 5 this morning trying to write this guide perfectly and shorten it for you in places where I deemed necessary. I also tried to check the language I used and if anyone wants, point out the grammatical errors or flaws in my English and I will rewrite it.

Oh yeah, please keep reminding me when you can to stay true to this Hex Teaching Quest. If I don't post up new stuff in days/weeks please Mods and Admins, remind me that I need to!

One day, I shall become, TUTORIAL-MAN: Superhero of writing overly long, overly annoying tutorials which most people probably won't read, but will give it a stab at the first 5 lines!
I knew, a "Bit about the Bit", but not this Much, So ThAnkS!! ;)
!!!Have GUTS???
Then show them Off!!! :p
Thanks given by:
Pretty great tutorial - I may have known about half of it already but at least this has freshed up my memory and given me new insights on how to calculate :p

So +1 thanks to you. (And it's my first one.)
Quote of the Day f***ing Year (Click to View)
Thanks given by: Eddie
Fixed a mathematical error there. (0xFF =255!)
Anyways, nice job. As far as tuts go this one is quite detailed.

On a side note:
When I was editing this I saw heaps of 'sup's. It was hilarious when I realised it meant superscript.
Hiding users' signatures and avatars was the best decision ever.
4ye 6anDy (Click to View)
We're watching you... (Click to View)
| Avatar made by Alectric |
Thanks given by: Eddie
Gives you a bit of a fit when you have to keep writing sup/superscript command on every line seriously.

Thanks for correcting me blow_fly :D.

Cheers for the response's guys. I'm already working on the next few tutorials which should be with you within a matter of days, one of them maybe even a day!


Edit: @Phil -
I await the day that those worlds will come true my friend. :D

Here are the answers to the questions as promised, every single last one of them. Read them but be honest with yourself that you actually attempted the questions and mark yourself properly. No I cannot force you to do this but it will be more helpful to you in the long run. If you got some answers wrong, please check to see why you went wrong - you'll be able to convert in no time! Enjoy!


The Lost Global Mod edited this post 07-23-2010 03:30 PM because:
working hard there eh? cat damnit sooner or later i gotta praise you for that lol.
One day, I shall become, TUTORIAL-MAN: Superhero of writing overly long, overly annoying tutorials which most people probably won't read, but will give it a stab at the first 5 lines!
Thanks given by: John Fighterli
Oh, you got a mistake in your conversions table (you skipped the decimal 29).
Quote of the Day f***ing Year (Click to View)
Thanks given by: Eddie
Atm I've only read decimal and binary. The tut's looking great and it's easy to understand (despite the over 1000 words).
Hope you don't mind me saving it in a text file to access it more easily.
If the decimal = base 10, binary = base 2, then the octal system (the one with digits from 0 to 7) will be base 8, right? Correct me if I'm wrong.
Again, thanks a lot for the tutorial. Pretty much helps me in counting in "another language".
[Image: abstractdaad.png]
Graphic Stuff|Tania|Indo Fighter|Sprites|Comics|
News of my days: My graphics skills will go better. Eventually...
Thanks given by:
You are 100% right Tania, the octal system does work using a base 8 (0-7) system. I forgot to mention that on the end... well I forgot to mention if anyone needed any other counting systems or questions about them to raise them.

@Ramond: Yes, I accidently skipped it. Now thats why I got to 32 when I was sure it wasn't supposed to happen. Thank you!

I'm glad it's helping you. ^^

One day, I shall become, TUTORIAL-MAN: Superhero of writing overly long, overly annoying tutorials which most people probably won't read, but will give it a stab at the first 5 lines!
Thanks given by: John Fighterli

Users browsing this thread: 2 Guest(s)