This commit is contained in:
Miloslav Ciz 2024-02-18 17:14:46 +01:00
parent 47a191f63e
commit a508d177e9
31 changed files with 1737 additions and 1707 deletions

View file

@ -2,6 +2,8 @@
The word binary in general refers to having [two](two.md) choices; in [computer science](compsci.md) binary refers to the base 2 numeral system, i.e. a system of writing numbers with only two symbols, usually [1](one.md)s and [0](zero.md)s. We can write any number in binary just as we can with our everyday [decimal](decimal.md) system, but binary is more convenient for computers because this system is easy to implement in [electronics](electronics.md) (a switch can be on or off, i.e. 1 or 0; systems with more digits were tried but unsuccessful, they failed miserably in reliability -- see e.g. [ternary](ternary.md) computers). The word *binary* is also by extension used for non-textual computer [files](file.md) such as native [executable](executable.md) programs or asset files for games.
Operations with binary values are very often handled with so called **[Boolean](bool.md) algebra**, which is originally a type of algebra that works with [sets](set.md) and their operations such as conjunction, disjunction etc. It's just a kind of abstract algebra, i.e. a set of values, operations and rules that are consistent and can be used in many situations; a Boolean algebra can generally operate with more than just two values, however as programmers only deal with 1s and 0s, they adopted the binary Boolean algebra, so in context of computers we understand Boolean algebra to be the one working with 1s and 0s and we interpret the operations of the algebra as [logic](logic.md) operations ([AND](and.md), [OR](or.md), NOT, ...). Boolean operations are so widely used that the word "boolean" is oftentimes used synonymously with "binary", i.e. many programming languages have e.g. a [data type](data_type.md) called `bool` that allows two values (*true* and *false*).
One binary digit can be used to store exactly 1 [bit](bit.md) of [information](information.md). So the number of places we have for writing a binary number (e.g. in computer memory) is called a number of bits or bit width. A bit width *N* allows for storing 2^N values (e.g. with 2 bits we can store 4 values: 0, 1, 2 and 3, in binary 00, 01, 10 and 11).
At the basic level binary works just like the [decimal](decimal.md) (base 10) system we're used to. While the decimal system uses powers of 10, binary uses powers of 2. Here is a table showing a few numbers in decimal and binary: