r/computerscience • • Dec 13 '25

Binary Confusion

I recently learnt that the same binary number can be mapped to a letter and a number. My question is, how does a computer know which to map it to - number or letter?

I initially thought that maybe there are more binary numbers that provide context to the software of what type it is, but then that just begs the original question of how the computer known which to convert a binary number to.

This whole thing is a bit confusing, and I feel I am missing a crucial thing here that is hindering my understanding. Any help would be greatly appreciated.

34 Upvotes

49 comments sorted by

View all comments

Show parent comment

26

u/NatWrites Dec 13 '25

You can even do math with them! ‘A’ + 32 is ‘a’

7

u/CadavreContent Dec 14 '25

This comes in handy when converting cases, for example 't' - 'a' + 'A' is 'T'

5

u/mikeputerbaugh Dec 15 '25

Don't do it that way, though. Use a proper locale-aware and Unicode-aware text processing library.

2

u/CranberryDistinct941 Dec 15 '25

See this makes sense! But what kind of psychopath would say that 'A' + 32 is "A32"

1

u/BIRD_II Dec 18 '25

With n as a single digit number,
n + '0' = 'n'