Welcome, seeker of knowledge! 🐧

This should serve as a short introduction to a fundamental thing in informatics: Number systems.
With a few lines about a practical example: hex editing. After all, this is hosted on a site for modifying your 3DS.

Hex and Hex Editor

In the left view within a hex editor you see pairs of hexadecimal digits.
Hexadecimal digits continue after 9 until the letter F.
Thus you get effectively a number system with 16 values:
{0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F}.

In a hex editor two hex digits are paired together so that you get a byte — 16*16=256).
On the right side the hex editor shows you one of 256 symbols for that byte.
Those symbols make it easier for humans to read! They are your friends.
Each hex editor users a different set for those 256 symbols, depending on the encoding it is using.
It is usually ASCII with something that builds on top of that (like ANSI or Unicode).


Bytes and converting to decimal

A byte consists of 8 bits (a bit is 0 or 1).
For example the decimal number 10 can be represented like this in binary:
0000 1010.
We put a space after four digits/bits to make it more readable (and for a upcoming neat trick).
Fun fact: four bits are called nibble in modern computing (or half byte).

To get a decimal number you go from right to left, multiply the rightmost digit with 1.
Multiply each following digit with double the number you multiplied the previous position with.
In other words: multiply each digit by 2 raised to the power of its position number.
To make it easier to understand:
0000 1010 written in rows from starting with the right most digit:
0*1 = 0*1 = 0
1*2 = 1*2 = 2
0*2*2 = 0*4 = 0
1*2*2*2 = 1*8 = 8
... (leaving the last four calculations for the left four bits out cause those are all zeros)
Now you calculate the values you got together: 8+0+2+0=10.
You can try the same with 1111 1111 and you should get 255.
Try it yourself with: 0010 1010.
Click after you tried it to get the solution You should get the decimal number 42.

Binary to hex

Now onto the litte trick I meantioned earlier.
A good reason to divide binary into blocks of four is that...
well what is binary 1111 in decimal? It is 15 (1+2+4+8)!
Yes, four binary digits (bits) represent 0 to 15 in decimal; 16 digits in total.
And this just nicely lines up with our hexadecimal system which also uses 16 values (reminder: 0 to 9 and A to F).

So for 0000 1010, for which we know is 10 in decimal, we put in A.
(count to 9 and then instead of continuing with 10,11,12,13,14,15 you still have the digits A,B,C,D,E,F in hex!:
DEC 01234567 89101112131415
HEX 01234567 89ABCDEF
).
For 1111 1111 you simply have two blocks with F: FF.
You can try that now with 0010 1010.
First block in hex 2
Second block in hex A

Convert hex back to decimal

You multiply each digit by 16 raised to the power of its position number.
(That's basically the same we did when converting binary to decimal.
But this time instead of doubling we add multiplies of 16)
So to get FF back to decimal you do this:
F*1 = 15*1 = 15
F*16 = 15*16 = 240
Add that (240+15) and you get 255 (the 256th number when counting from zero)!

More complex example with the funny hex number 01 A4 (0000 0001 1010 0100 in binary):
4*1 = 4*1 = 4
A*16 = 10*16 = 160
1*16*16 = 1*256 = 256
0*16*16*16 = 0*4096 = 0
Add that together (256+160+4) and we get 420 in decimal 🥦
For a test whether you understood that:

Denotion of number systems

HEX can be denoted in at least three different ways: DEC can be denoted by adding a d after the value (useful on paper when multiple systems are used. E.g. 1d; 10d; 17d).
BIN can be denoted in at least two different ways:

Numbers that aren't whole/natural/ℕ numbers

So far integral data types like nibble and byte were mentioned.
Those can only display whole numbers. You might already see the problem...
9 divided by 2? 4
This is what would be stored in a variable of an integral data type at least.
Pseudocode:
integer result = 9/2
print "9 divided by 2? valueOfvariable(result)."

The digits after the decimal point (.) are cut off.
That's inconvient but luckily there are more kind of data types.
Your new friend will be the ✨ float ✨. 9/2 will be 4.5 — as expected!
With floating-point arithmetic you get to keep digits after the decimal point!
(It's not perfect but a good enough solution for us)

Floating-point arithmetic (with hex)

You might ask: How do those position values work on the 3DS? (seen e.g. in the coordinates tool).
The hexadecimal there don't seem to correspond to the decimal value.
But what does the 3DS use here? The answer: 32-bit floating-point numbers (IEEE 754 standard).

For now, watch those videos to convert from 32-bit floating point numbers to hexadecimal and back:
https://www.youtube.com/watch?v=DIWg-fI7vUQ
https://www.youtube.com/watch?v=RdGPgFKXB_A
Those aren't perfect, contain some confusing statements und partly talk about unecessary things.
I might add a better textual step-by-step guide in the future.
You could take e.g. 168 (00002843h) or 120 (0000F042h) as example values to calculate with.
Those are the X and Y positions of the 3DS battery icon in the Home Menu.

However, you will notice that you won't really get the expected results when following the videos.
On a closer look after the second video, you will notice the byte order seems to be different.
And yes, this is due to the so-called endianess.
The 3DS uses little endian. You don't really need to care about this further;
if you want to calculate using the method from the first video just swap e.g. 00 00 28 43 to 43 28 00 00.

Notes

There are other ways to convert between numbers systems but those are the easiest in my opinion.
The broccoli emote is used for cannabis in Germany. Fun fact: young german people say "Bubatz".
If you got everything, you are likely more educated than the typical university IT student on number systems.
Most things are easy (after some time) — education systems and people holding back information make you feel dumb.

TODO: Include a training program with random generated values.
TODO: Add images and better formatting.

© derberg, schrmh & Kazue