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 little trick I mentioned 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 inconvenient but luckily there are more kinds 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 e.g. due to limited preciseness but it's 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 doesn'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).

Since each pair of hex digits represents one byte (8 bits), four pairs are needed for 32 bits.
From the end to the start,
with the 23 (mantissa) bits we will get the number we are looking for,
after we used the 8 (exponent) bits which tell us where to place the binary point
and the first (sign) bit tells us if we have a positive (0) or negative (1) number

The exponent value is biased with an offset of 127 that you just subtract (half of the 254 available exponent values; 0 and 255 are reserved).
And left of the binary point next to the Mantissa there is one implicit leading bit of value 1.
Let's just do two examples right away to make this a bit more clear.
Both have the same mantissa for the same reason.
(I think in the case of the 3DS the mantissa is often just a bunch of 0s anyways and this makes me question why a float is used... but well...)

HEX C0 D0 00 00
BIN 11000000 11010000 00000000 00000000
Sign Exponent Mantissa
negative 129 (-127) ⇒ +2 1.mantissa (w/o trailing zeros) ⇒ 1.101

HEX 3E 50 00 00
BIN 00111110 01010000 00000000 00000000
Sign Exponent Mantissa
positive 124 (-127) ⇒ -3 1.mantissa (w/o trailing zeros) ⇒ 1.101
To easily find out what number we have, we first shift by the result of the biased exponent bits.
On paper this means 2 to the right in case of C0D00000:
Start:1.101
110.1
...and 3 to the left in case of 3E500000:
Start:1.101
0.001101
(filled up with zeros)

Alternative way of displaying the same thing
(0s and 1s move instead of binary point) including exponents for calculation:
For C0D00000:
Exponentiations 2⁰2⁻¹2⁻²2⁻³
Decimal value 4210.50.250.125
Binary Decimal
Start:1.101 1.625
×2:11.01 3.25
×2:110.1 6.5
(It's actually -6.5 due to the sign bit)
For 3E500000:
Exponentiations 2⁰2⁻¹2⁻²2⁻³2⁻⁴2⁻⁵2⁻⁶
Decimal value 4210.50.250.1250.06250.031250.015625
Binary Decimal
Start:1.101 1.625
÷2:0.1101 0.8125
÷2:0.01101 0.40625
÷2:0.001101 0.203125
(As you can see, for negative powers in base 2 we effectively just half our number multiple times instead of doubling it. For 2⁻³ we half three times.)

You might have already guessed that you don't really need to visually shift and can just calculate.
But shifting and then calculating might save you time bothering with long values after the binary point...

Also while in case of C0D00000 it's basically just (1+0.5+0.125) × 2² = 6.5. (Well, actually -6.5 due to the sign bit!)
The (1+0.5+0.125) × 2⁻³ of 3E500000 is a little bit harder to calculate without a calculator.
(Tho in this case × 2⁻³ can easily be written as × 1/23 or × ⅛ or ÷ 8.)

This has been a bit. Before calculating back from a decimal number to a float in the IEEE 754 binary32 format...
Let's see what you would get for 00002843h and 0000F042h which represent the X and Y positions of the 3DS battery icon in the Home Menu.
...
No, before you actually do this you need to be aware that there is something called endianess which basically determines the order of our hex pairs.
Simply invert the order of the pairs. In this case this gets us 43 28 00 00 and 42 F0 00 00. Now calculate with these.
X value of 3DS battery icon? (Hex exditor: 00 00 28 43) 168.0
Y value of 3DS battery icon? (Hex editor: 00 00 F0 42) 120.0

For converting from a decimal number back to a single-precision floating-point in hex, you can follow e.g. this video for now:
https://www.youtube.com/watch?v=RdGPgFKXB_A
I will replace this video link with a text tutorial later.

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