DEV Community

ingaharutyunyan
ingaharutyunyan

Posted on

About binary numbers

Binary, or base 2, describes the two states- 1 and 0, which are widely used in computer programming from ASCII to truth tables.

In ASCII (American Standard Code for Information Interchange) the binary language is used to express every number computable. This is done by translating our understanding of modern numbers, Base 10 (numbers 0–9) into Base 2 (0–1) through quick computation (2^n*a+…+2²*z+2¹*y+2⁰*x). This way, computers can understand what human numbers mean, and perform addition, multiplication and other transformations using these two numbers. Other bases like Base 16 use letters as an addition to Base 10, ranging from 0–9 to A-F, which are known as hexadecimal numbers, and are handy for operations that require more computing capacity.

Binary numbers can be added, subtracted, divided and multiplied the same as 0-9 numbers, just with a slightly different method. For example, by our understanding, 1+1=2, but because there is no '2' symbol in binary code, it's 1+1=10, as 10 = 2 = (2¹*1+0*2⁰). 1-1 would obviously be 0. 1*1 would remain 1 as multipliers are simply scalars of the original number given, and dividers are reverse multipliers.

Each number (1 or 0) takes up the space of one bit, and a string of 8 bits measure up to one byte. Therefore, computers with less computational capacity usually have less storage in them (but the upside is that they usually work faster).

Binary is also used to compute Boolean statements like: If x is true (1), then execute y, or if x is false (0), don’t execute y. Boolean values are also used in truth tables where more specific situations in the computer must be identified, using AND, OR, nAND, nOR, xAND etc. These two values can be stacked up to check the presence of three or more variables, and other cool stuff, which shows how much you can achieve with just two numbers.

Top comments (0)