How tf does binary code work.

628 views

it’s just a bunch of 0’s and 1’s.. like I can just put a bunch of them and somehow make a sentence??? like what does this mean -> 010100101001010010 (i legit just spammed 0’s and 1’s)

In: 0

26 Answers

Anonymous 0 Comments

> How tf does binary code work.

Somebody says “Here’s how we’ll interpret these ones and zeros,” and then somebody uses that interpretation to do something — usually a computer program, but it could also be a chip or a circuit or even something non computer related.

> like I can just put a bunch of them and somehow make a sentence

If you define sequences of ones and zeros to be letters (and other keyboard symbols like punctuation marks), then yes.

Originally every computer maker made up their own sequences of 0’s and 1’s for letters and punctuation marks and so on. But this got unsustainable once we started to make more computers and we wanted to make different kinds of computers able to talk to each other. So in the 1960’s a committee came up with a standard table called [ASCII](https://en.wikipedia.org/wiki/ASCII). Most computers use ASCII or its descendants today.

> what does this mean -> 010100101001010010

It means what you want it to mean. If you think maybe it’s a sentence in ASCII, you go by the ASCII table, and characters are 7 bits in the table, so breaking it into 7-bit groups you get 0101001 0100101 with four bits 0010 left over. Which translates to the following two characters:

)%

Most computers use 8-bit bytes though. If you interpret it as 8-bit bytes you get 01010010 10010100 with two bits 10 left over. The first character is a capital letter R in ASCII, the second one isn’t an ASCII character at all.

Conveniently MS-DOS (an old operating system) has a [bigger table](https://en.wikipedia.org/wiki/Code_page_437) that assigns a symbol to all possible 8-bit bytes. The table’s in base-16 (“hexadecimal” or “hex” for short), and binary to hex conversion is easy; you just break the digits in blocks of 4 and translate them like this:

0000 -> 0 0001 -> 1 0010 -> 2 0011 -> 3
0100 -> 4 0101 -> 5 0110 -> 6 0111 -> 7
1000 -> 8 1001 -> 9 1010 -> A 1011 -> B
1100 -> C 1101 -> D 1110 -> E 1111 -> F

So the 10010100 translates to 94 hex, and row 9, column 4 of the MS-DOS table says it represents an o with two tiny insect friends, like this: ö ([see here for more details](https://en.wikipedia.org/wiki/%C3%96) ). So with 8-bit groups interpreted with the MS-DOS table, your sequence corresponds to the two letters:

Maybe it’s part of some text about [Wilhelm Röntgen](https://en.wikipedia.org/wiki/Wilhelm_R%C3%B6ntgen)?

The 128 possible ASCII characters, or the 256 possible MS-DOS characters, work well enough for English and most western European languages. But they aren’t nearly enough to represent all the other alphabets of the world at once (India, Russia, Middle East, the many African languages) and certainly aren’t enough for languages like Chinese with thousands of characters.

So after a multi decade compatibility nightmare of multitudes of different national / regional text coding systems used by different parts of the world, in the past 15 years or so most programs and OS’s have standardized on a coding scheme called [UTF-8](https://en.wikipedia.org/wiki/UTF-8) whose mission is to standardize the sequence of 1’s and 0’s everyone uses to represent every symbol in every writing system humanity has ever invented (including stuff like 日本語 Japanese characters and a downright frightening number of symbols and emojis 😇 ☢️ 🐢 😂 which, you’ll notice, I can put in a Reddit post with no trouble, even if neither you nor I nor the IT elves of Reddit have selected “Japanese” as our OS’s main language).

You could also interpret your sequence of bits as a number. Usually numbers are done like this:

– Read the bits off from right to left
– Multiply the first (rightmost) bit by a place value of 1
– Multiply each next bit by a factor 2 times the previous bit’s place value
– Add all the products together

You read decimal numbers the same way, except you go up by a factor of 10.

So in our number system, 1492 = 2×1 + 9×10 + 4×100 + 1×1000. In binary, your number is:

01.01001010.01010010 =
0x1 + 1×2 + 0x4 + 0x8 + 1×16 + 0x32 + 1×64 + 0x128
+ 0x256 + 1×512 + 0x1024 + 1×2048 + 0x4096 + 0x8192 + 1×16384 + 0x32768
+ 1×65536 + 0x131072

which means 010100101001010010 is the number 84,562.

You are viewing 1 out of 26 answers, click here to view all answers.