Hexadecimal Numbers

hey developers :))

i got an answer today about something i’ve stumbled across midway through my project

if you was to run this bit of code below

print(0x60)

it would output 96, so i thought oh it must add on 36 to whatever the number is after the 0x

so then i ran this code expecting it to output 46

print(0x10)

but it outputted 16

so i was just playing around with this and i realised how it works, for every 10 numbers the addition increments by six

so 0x10 = 16, 0x20 = 32, 0x30 = 48, 0x44 = 68

i write this all out because it kind of confused at first, hope this helps someone :))

^^ note im pretty sure increments fully change after 0x100, ill do a future post about this if i figure it out unless someone comments it down below

2 Likes

That would explain the “Hexa”. This probably wasn’t the correct category but who am I to judge heh🤷‍♂️

It’s how hex numbers are converted to normal ones.

the “0x” indicates its a hex numbers then you multiply the numbers after “0x” from right to left by 1 (16^0), 16, 16 * 16, 16 * 16 * 16 etc.

It’s just the next powers of 16 multiplied by that number. Hope this helps!

1 Like

Lol yeah that is true this is the wrong category but someone would come here to ask for help and if they see this post by any chance they would most likely read it and find out. But either ways I didn’t know what category to post it in

Also forgot to add that the numbers are summed up together after multiplication.

so 0x12 would be:

2 * 1 = 2
1 * 16 = 16
2 + 16 = 18
0x12 = 18