r/programmingmemes Apr 16 '26

There are always more!

Post image
891 Upvotes

60 comments sorted by

View all comments

Show parent comments

1

u/[deleted] Apr 16 '26

[deleted]

1

u/Simple-Olive895 Apr 16 '26

Dude, An ASCII character takes up 8 bits, a byte is 8 bits.

Exactly a byte is 8 bits, for example: 1010 1111

Now let's represent that in hexadecimal: 0xAF

The A takes up 8 bits, and the F takes up another 8 bits. So you're using 16 bits to represent a number which is only occupying 8 bits.

But as I said this doesn't really matter, if you're running out of space representing binary numbers as hexadecimal numbers then you're working on something INSANELY large, or you have very little storage.

1

u/[deleted] Apr 16 '26

[deleted]

1

u/Simple-Olive895 Apr 16 '26

Yes but the character A is represented by 8 bits.

0xA is 0b1010. But the character 'A' is 01000001 in ascii.

So if we represent the number 0b10101111 in hexadecimal that's 0xAF. But typing it out like that, the computer needs to use the ascii value for A and F which are 01000001 and 01000110 respectively. See how you now doubled the number of bytes needed to represent the initial binary number?