Viewing a single comment thread. View all comments

dmullaney t1_j6h2s6j wrote

When you type 4 in your keyboard, the button you pushed presses on one of many physical switches, which each produces a unique number (in binary) called a scan code which tells your computer which of the many keys you pressed. At point the computer knows which button you pressed, but not what that button represents (you may have seen keyboards for different languages have different physical layouts)

There is then, in the operating system, there is a table which knows the layout and can convert those scan codes into the appropriate binary representation of the number, letter or symbol that the key you pressed represents

11

Loki-L t1_j6h6z19 wrote

To add to that, in most circumstances pressing four on the keyboard will not result in 00000100 binary being stores, but instead 00110100.

The keystrokes get normally stored as characters not numbers and this character just happens to be a digit.

The value of the characters for 0 to 9 are not the values of the numbers 0 to 9, but 48 (00110000) added to them.

To actually treat what you enter as a number rather than a string of characters the computer needs to internally convert them.

3

R0oty OP t1_j6h3x7m wrote

Thanks for the explanation.

2