Binary code

Can someone please explain binary code to me.

Normal numbers are base 10. Binary is base 2. This means the columns represent values of 1, 2, 4, 8, 16 instead of 1, 10, 100, 1000. You "carry the 1" when a column gets to 2 instead of 10.

The value 0b1011 in binary is 1+2+8 = 11.


In programming binary can be used to represent things other than simple numbers. For example a game programmer could make different bits of a byte indicate what items a player has possession of.

>Normal numbers are base 10
10 in what base :^)

expounding on the previous user's post, this is essentially how addition is performed in computers on adders. Depending on how much detail you want, you may want to look into computer architecture to see why binary is convenient and necessary. It may also help you understand more.

Say you have a binary adder. What you are doing is saying what input "valves" are turned on (in the case of electronic computers, this would be applying the proper voltage to the right input line). For the binary adder, you then have a bank of inputs for number A written in binary and another for number B also in binary. The output is then a single bank of output lines. The ones with a voltage are then "on" while the others are off, which again translates to a binary number that is the sum of the two inputs. So, to sum up: binary code is just a series of instructions of what switches are "on" and which are "off".

It's the language of moisture vaporators.

Now, get back to your chores.

Think of the binary (base 2) much like minutes (base 60).
[eqn]
\begin{aligned}
0 + 1 + 2 + &\ldots + 58 + 59 \\
0 + 1 + 10 + &\ldots
\end{aligned}
[/eqn]

Binary code by itself doesn't mean shit unless you know its context, best you can do is translate it to deci or hexa

In English we represent our numbers in base 10, using the symbols, 0 1 2 3 4 5 6 7 8 9, and we basically count numbers like a car meter with them with an infinite slot of 0s. So we go ...001 then ...002, etc until we get to ...009, and go to the next slot starting from the start so ...010, which is the number of ten, and then we go back to fill the first slot again with our unused numerals so ...011 would be eleven.

Now take this idea, but put it in base 2 (binary), which only uses 2 symbols to represent numbers which are 0 and 1. Because the counting only has 2 symbols, the looping starts much earlier. So ..001 would be one, and ...010 would be two, and we go back to our first slot with our unused numerals, so ...011 would be three, and then ...0100 would be four, and ...0101 would be five and so on.

The easy way to turn binary into base 10 (decimal) is to place the total number of variations that can be created in the accumulation of each slot, and just add them up. Here, the variations are placed above the slot:

...16 8 4 2 1
... 0 0 0 1 2

would be 2 + 1 = 3

... 16 8 4 2 1
... 1 1 0 1 0

would be 16 + 8 + 2 = 26

There are other bases, as you may guess. Base 5 only uses 5 symbols. 0 1 2 3 4, and you can use those to count as well. 1 2 3 4 10 11 12 13 14 20 is 1 2 3 4 5 6 7 8 9 10.

Base 16 (hexadecimal) uses 16 symbols: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, F (using alphabets to represent ten, eleven, twelve, thirteen, fourteen and fifteen) counting with these is just like it has been done previously, but we add more symbols to the mix. 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 would be in base 10: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32

>...16 8 4 2 1
>... 0 0 0 1 2

Ah shit, I mean
...16 8 4 2 1
... 0 0 0 1 1

normal counting is base 10 (decimal)

binary is just base 2

usually it is translated to base 8 (octal) or base 16 (hexadecimal)

this is just easy to interpret by computers (pic related) because digital logic

Instead of representing information as symbols like letters or numbers, you represent it as patterns of "on" and "off" states - any two distinct states of a "binary" (two-option) choice.

You can represent any kind of data this way: For instance, you might assign a distinct pattern of binary ons and offs to each letter of the alphabet and keyboard symbol, so you can encode and decode text into binary. Or you might use a base-2 number system, and assign on to 1 and 0 to off, and represent numbers. With more complex encodings you can represent strings, lists, trees, arrays, pictures, sound, video, etc, etc.

In computers, the data in memory can also represent the code for the next computer instruction to execute, or numbers representing the menory address to look for something at. In this way, whole programs and the data they operate on can be encoded as one long string of bits, with the first part treated as instructions telling the computer how to interpret the upcoming bits.

Im stupid...is binary universal or did we invent it

The latter; the earliest computers used decimal.

Binary hardware is just the simplest to.build.

We count from 0 to 9 in our normal decimal system. Once that first digit is full (9), then we "open" a new digit. That would be 10. Then we count from 0 to 9 again (10, 11, 12, ..., 19), rinse and repeat.

The binary system just means one digit can only hold 2 values (zero and one) instead of the 10 values (0 to 9) per digit of the decimal system.
You count up from 0 to 1, then you open a new digit. Therefore a "10" in binary would be a "3" in decimal.
It works exactly like decimal system, you count up and then open a new digit every time you run out of space: 0, 1, 10, 11, 100, 101, 111, 1000, 1001, 1011, etc.


The binary system is useful for telling computers what to do, because they are controlled with electrical switches. A switch can either be off (0) or on (1), just like a binary digit.

Imagine two electrical circuits, the first circuit turns on a lamp if it gets an electrical current and the second circuit spins a fan.
Now you want to control the lamp circuit, you can easily do that by putting a switch before it. Turn the switch on and the circuit gets turned on, the lamp shines. Turn the switch off, then the lamp turns off.
You want to control the fan circuit? Same thing, put a switch before it.
What possible switch states do we have with this? Both are off (00), first is on (01), second is on (10), both are on (11).
Add a third circuit with another switch controlling it, now we get the possible switch states: 000, 001, 010, 011, 100, 101, 111

Do you see how useful binary is to represent these switch states?

>000, 001, 010, 011, 100, 101, 111
Forgot 110

Numbers in base ten (normal counting) start at 0, then 1, 2.... 8, 9, then 10, 11, 12... 98, 99, then 100, 101, and so on. It's called base ten because there are ten digits with which to represent numbers.

But there are other counting systems, one of which is referred to as base two, where there are only two digits with which to represent numbers. it starts with 0, then 1, then, 10, 11, 100, 101, and so on.

Binary code is represented as base two numbers. A "0" represents when a circuit is off, and "1" represents when it is on. So 1000101 is On Off Off Off On Off On. The information contained in whether one given circuit is on or off is 1 bit of information. When a processor is "8-bit", that means it can hold a piece of information that is up to 8 bits in size, which is essentially 2^8 or 256. This is why PacMan could only have 255 levels (256 possible on/off combinations, but one of these is 00000000, which is 0, so a 255 maximum).

There's more and I skipped over stuff at the end, but it's late and I'm sure others can be more helpful, I only took a basic programming course in HS and have picked up a few things from Veeky Forums and writing ver rudimentary code. But it helps in remembering the info better to actually use it, so Imma post this anyway and push the thread along. Peace.

dis many: **********

The 1s and 0s tell the computer what to do based on its architecture. The 1s and 0s come in strings and tell the computer which instructions to perform, which operations to do on which numbers, and where to store and load from memory.

>1st post
>/thread
>we'll just keep posting

Oh, /sci, what have you become...

Play minecraft, fuck around with redstone.

Minutes aren't really base 60, though. Counting behaves exactly as base 10 until you reach a full hour; you'd need 60 symbols otherwise. Similar for hours and seconds, but then suddenly averted for milliseconds and below. Even worse for days, months and years. Our time units are horrifying abortions of arbitrary custom in a world where pretty much all other units are streamlined and standardized.