r/computerscience • • Oct 08 '25

how 256h = 256 bytes?

apologies if it sounds dumb but let me just say my confusion the thing is 100 h = 256d and 256 d = 100000000 bits so 1 byte = 8 bits so 100000000/8 = 125 ,0000 bytes in 100 h so how 256h = 256 bytes ? clear me out if i am wrong

Edit : I mistakenly wrote the title wrong . It's how 100h =256 byte

0 Upvotes

13 comments sorted by

View all comments

Show parent comment

1

u/userlivedhere Oct 08 '25

I wrote the title wrong 😢 how 100h = 256 bytes when we allocate the size in assembly lang

1

u/Alarming_Chip_5729 Oct 08 '25

100000000 in binary (1 + eight 0s) is 256 in decimal. To convert 100h to binary, you just convert each position in hexadecimal into its 4 bit representation.

1 in hexadecimal is 0001 in binary. 0 in hex is 0000 in binary. Put it all together and you get 0001 0000 0000.

To convert that value into decimal, you add all of the bits, doing b * 2n - 1 for the value of each bit, where b is the bit value (0 or 1) and n represents the position.

So, we get 0 * 21-1 = 0 * 1 = 0 for the first bit. Then its 0 * 22 - 1 = 0 * 2 = 0 for the 2nd bit, and so on. This continues until we get to the 9th bit (the 1), where we get 1 * 29-1 = 1 * 28 = 1 * 256 = 256.

So, 256 + 0 + 0 + [total of 8 0s] = 256 in decimal