Reading binary as decimal or ascii confusion

Viewed 33

I was looking over some hex data the other day and I’ve got a bit confused with something.

If I see the hex code: #41, 65 in decimal or 0100 0001 in binary.

Fine!

But, what confuses me is that #41 is the code for letter A in ascii.

So when I was looking at the stream of hex bytes in sublime it actually picked up it as “A” and not the number 65.

So the confusion is, how did it know to represent this hex or binary as the letter A instead of the integer 65? Is there some kind of flag in the binary that sublime used to determine if it should show the character or the integer?

In other words, if someone gave me a byte of binary how do I then determine if they wanted me to see it as ascii or an integer without them actually telling me?

1 Answers

I believe the answer to this question (albeit very late) is because the ascii code for the letter A is in the 65th index position of the character set.

The number 6 would be 0000 0110, or just "6". 65 in a text string is just a collection of individual numbers, and not something like an int data type.

Admittedly, I don't know how you'd handle identifying if someone is asking you to give them the ascii value for the hex, or the denary value of the hex. I'm still too new to this concept.

Here's where I derived my answer: https://www.bbc.co.uk/bitesize/guides/zp73wmn/revision/5

Related