diff --git a/binary.md b/binary.md new file mode 100644 index 0000000..d788eae --- /dev/null +++ b/binary.md @@ -0,0 +1,34 @@ +# Binary + +Binary refers to to having two 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. Binary is used in computers because this system is easy to implement in electronics (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). The word *binary* is also sometimes used as a synonym for a native [executable](executable.md) program. + +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). + +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. + +For **example** let's have a number that's written as 10135 in decimal. The first digit from the right (5) says the number of 10^(0)s (= 1) in the number, the second digit (3) says the number of 10^(1)s (= 10), the third digit (1) says the number of 10^(2)s (= 100) etc. Similarly if we now have a number **100101** in binary, the first digit from the right (1) says the number of 2^(0)s (= 1), the second digit (0) says the number of 2^(1)s (= 2), the third digit (1) says the number of 2^(2)s (=4) etc. Therefore this binary number can be **converted to decimal** by simply computing 1 * 2^0 + 0 * 2^1 + 1 * 2^2 + 0 * 2^3 + 0 * 2^4 + 1 * 2^5 = 1 + 4 + 32 = **37**. + +To **convert from decimal** to binary we can use a simple [algorithm](algorithm.md) that's derived from the above. Let's say we have a number *X* we want to write in binary. We will write digits from right to left. The first (rightmost) digit is the remainder after integer division of *X* by 2. Then we divide the number by 2. The second digit is again the remainder after division by 2. Then we divide the number by 2 again. This continues until the number is 0. For example let's convert the number 22 to binary: first digit = 22 % 2 = **0**; 22 / 2 = 11, second digit = 11 % 2 = **1**; 11 / 2 = 5; third digit = 5 % 2 = **1**; 5 / 2 = 2; 2 % 2 = **0**; 2 / 2 = 1; 1 % 2 = **1**; 1 / 2 = 0. The result is **10110**. + +TODO: operations in binary + +In binary it is very simple and fast to divide and multiply by (powers of) 2, just as it is simply to divide and multiple by (powers of) 10 in decimal (we just shift the radix point, e.g. the binary number 1011 multiplied by 4 is 101100, we just added two zeros at the end). This is why as a programmer **you should prefer working with powers of two**. + +Binary can be very easily converted to and from [hexadecimal](hexadeciaml.md) and [octal](octal.md) because 1 hexadecimal (octal) digit always maps to exactly 4 (3) binary digits. E.g. the hexadeciaml number F0 is 11110000 in binary. + +We can work with the binary representation the same way as with decimal, i.e. we can e.g. write negative numbers such as -110101 or [rational numbers](rational_number.md) such as 1011.001101. However in a computer memory there are no other symbols than 1 and 0, so we can't use extra symbols such as *-* or *.* to represent such values. So if we want to represent more numbers than non-negative integers, we literally have to only use 1s and 0s and choose a specific **representation**, or **format** of numbers -- there are several formats for representing e.g. [signed](signed.md) (potentially negative) or rational numbers, each with pros and cons. The following are the most common number representations: + +- **[two's complement](twos_complement.md)**: Allows storing integers, both positive, negative and zero. It is **probably the most common representation** of integers because of its great advantages: basic operations (+, -, *) are performed exactly the same as with "normal" binary numbers, and there is no negative zero (which would be an inconvenience and waste of memory). Inverting a number (from negative to positive and vice versa) is done simply by inverting all the bits and adding 1. The leftmost bit signifies the number's sign (0 = +, 1 = -). +- **[sign-magnitude](sign_magnitude.md)**: Allows storing integers, both positive, negative and zero. It's pretty straightforward: the leftmost bit in a number serves as a sign, 0 = +, 1 = -, and the rest of the number is the distance from zero in "normal" representation. So e.g. 0011 is 3 while 1011 is -3. The disadvantage is there are two values for zero (positive, 0000 and [negative](negative_zero.md), 1000) which wastes a value and presents a computational inconvenience, and operations with these numbers are more complicated and slower (checking the sign requires extra code). +- **[one's complement](ones_complement.md)**: Allows storing integers, both positive, negative and zero. The leftmost bit signifies a sign, in the same way as with sign-magnitude, but numbers are inverted differently: a positive number is turned into negative (and vice versa) by inverting all bits. So e.g. 0011 is 3 while 1100 is -3. The disadvantage is there are two values for zero (positive, 0000 and [negative](negative_zero.md), 1111) which wastes a value and presents a computational inconvenience, and some operations with these numbers may be more complex. +- **[fixed point](fixed_point.md)**: Allows storing [rational numbers](rational_number.md) (fractions), i.e. numbers with a radix point (such as 1101.011), which can also be positive, negative or zero. It works by supposing a radix point at some fixed position in the binary representation, e.g. if we have an 8 bit number, we may consider 5 leftmost bits to represent the whole part and 3 rightmost bits to be the fractional part (so e.g the number 11010110 represents 11010.110). The advantage here is extreme simplicity (we can use normal integer numbers as fixed point simply by imagining a radix point). The disadvantage may be low precision and small range of representable values. +- **[floating point](float.md)**: Allows storing [rational numbers](rational_number.md) in great ranges, both positive, negative and zero, plus some additional values such as [infinity](infinity.md) and *[not a number](nan.md)*. It allows the radix point to be shifted which gives a potential for storing extremely big and extremely small numbers at the same time. The disadvantage is that float is extremely complex, [bloated](bloat.md), wastes some values and for fast execution requires a special hardware unit (which most "normal" computers nowadays have, but are missing e.g. in some [embedded systems](embedded.md)). + +As anything can be represented with numbers, binary can be used to store any kind of information such as text, images, sounds and videos. See [data structures](data_structure.md) and [file formats](file_format.md). + +## See Also + +- [bit](bit.md) +- [hexadecimal](hexadeciaml.md) +- [data structure](data_structure.md) +- [data type](data_type.md) \ No newline at end of file diff --git a/often_confused.md b/often_confused.md new file mode 100644 index 0000000..ada7dc9 --- /dev/null +++ b/often_confused.md @@ -0,0 +1,65 @@ +# Often Confused Terms + +There are many terms that are very similar and are sometimes used interchangeably. This isn't wrong per se, a slight difference may be insignificant in certain contexts. However it's good to know the differences for those cases when they matter. The following list tries to document some of the often confused terms. + +- **[AI](ai.md)** vs **[machine learning](machine_learning.md)** +- **[algorithm](algorithm.md)** vs **[program](program.md)** +- **[analog](analog.md)** vs **[mechanical](mechanical.md)** +- **[anarchy](anarchism.md)** vs **[chaos](chaos.md)** +- **[argument](argument.md)** vs **[parameter](parameter.md)** +- **binary** vs **[executable](executable.md)** +- **[array](array.md)** vs **[list](list.md)** +- **[cepstrum](cepstrum.md)** vs **[spectrum](spectrum.md)** +- **[assembler](assembler.md)** vs **[assembly](assembly.md)** +- **[causation](causation.md)** vs **[correlation](correlation.md)** +- **[chaotic](chaos.md)** vs **[random](random.md)** vs **[pseudorandom](pseudorandom.md)** +- **[class](class.md)** vs **[set](set.md)** +- **[closed source](closed_source.md)** vs **[proprietary](proprietary.md)** +- **[CLI](cli.md)** vs **[TUI](tui.md)** vs **[terminal](terminal_emulator.md)** vs **[console](console.md)** +- **[color model](color_model.md)** vs **[color space](color_space.md)** +- **[communism](communism.md)** vs **[Marxism](marxism.md)** +- **[computer language](computer_language.md)** vs **[programming language](programming_language.md)** +- **[computer science](compsci.md)** vs **[information technology](it.md)** vs **[informatics](informatics.md)** +- **[concurrency](concurrency.md)** vs **[parallelism](parallelism.md)** +- **[constant](constant.md)** vs **[literal](literal.md)** +- **[coding](coding.md)** vs **[programming](programming.md)** +- **[codec](codec.md)** vs **[container format](container_format.md)** +- **[coherence](coherence.md)** vs **[consistency](consistency.md)** +- **[convolution](convolution.md)** vs **[correlation](correlation.md)** +- **[copyright](copyright.md)** vs **[patent](patent.md)** vs **[trademark](trademark.md)** +- **[cryptography](cryptography.md)** vs **[security](security.md)** +- **[data](data.md)** vs **[information](information.md)** +- **[data structure](data_structure.md)** vs **[data type](data_type.md)** +- **[decentralized](decentralization.md)** vs **[distributed](distributed.md)** +- **[declaration](declaration.md)** vs **[definition](definition.md)** +- **[digital](digital.md)** vs **[electronic](electronics.md)** +- **[directed acyclic graph](dag.md)** vs **[tree](tree.md)** +- **[directory](directory.md)** vs **[folder](folder.md)** +- **[discrete Fourier transform](dft.md)** vs **[discrete time Fourier transform](dtft.md)** +- **[emulation](emulation.md)** vs **[simulation](simulation.md)** +- **[equation](equation.md)** vs **[expression](expression.md)** vs **[inequality](inequality.md)** +- **[equivalence](equivalence.md)** vs **[implication](implication.md)** +- **[error](error.md)** vs **[exception](exception.md)** vs **[fault](fault.md)** vs **[failure](fail.md)** +- **[evolutionary programming](evolutionary.md)** vs **[evolutionary algorithm](evolutionary.md)** vs **[genetic programming](genetic_programming.md)** vs **[genetic algorithm](genetic_algorithm.md)** +- **[floating point number](float.md)** vs **[real number](real_number.md)** +- **[font](font.md)** vs **[typeface](typeface.md)** +- **[free software](free_software.md)** vs **[open source](open_source.md)** vs **[public domain](public_domain.md)** vs **[source available](source_available.md)** vs **[freeware](freeware.md)** +- **[GNU](gnu.md)/Linux** vs **[Linux](linux.md)** +- **[hypothesis](hypothesis.md)** vs **[theory](theory.md)** vs **[conjecture](conjecture.md)** +- **[ID](id.md)** vs **[token](token.md)** vs **[hash](hash.md)** vs **[handle](handle.md)** vs **[identifier](identifier.md)** +- **[infinite](infinity.md)** vs **[arbitrarily large/unbounded](unbounded.md)** +- **[internet](internet.md)** vs **[web](web.md)** +- **[Java](java.md)** vs **[JavaScript](js.md)** +- **[kB/mB/gB/tB](memory_units.md)** vs **[KiB/MiB/GiB/TiB](memory_units.md)** +- **[latency/ping/lag](latency.md)** vs **[throughput/bandwidth](throughput.md)** +- **[leftism](left_right.md)** vs **[pseudoleftism](pseudoleft.md)** +- **[method](method.md)** vs **[methodology](methodology.md)** +- **[modem](modem.md)** vs **[router](router.md)** +- **[NP](p_vs_np.md)** vs **[NP-hard](np_hard.md)** +- **[path tracing](path_tracing.md)** vs **[ray tracing](ray_tracing.md)** vs **[ray casting](ray_casting.md)** +- **[principal square root](principal_sqrt.md)** vs **[square root](sqrt.md)** (especially when defining [i](i.md)) +- **[probability](probability.md)** vs **[probability density](probability_density.md)** +- **[pointer](pointer.md)** vs **[reference](reference.md)** +- **[shading](shading.md)** vs **[shadows](shadow.md)** +- **[science](science.md)** vs **[soyence](soyence.md)** +- **[webpage](webpage.md)** vs **[website](website.md)** \ No newline at end of file diff --git a/p_vs_np.md b/p_vs_np.md index 80a46ac..1571a29 100644 --- a/p_vs_np.md +++ b/p_vs_np.md @@ -8,7 +8,7 @@ It is believed and sometimes relied on that P != NP (in which case P would be a In the context of [computational complexity](computational_complexity.md) of algorithms we talk about different types of algorithm time complexities, i.e. different "speeds" of algorithms. This "speed" doesn't mean actual running time of the algorithm in real life but rather how quickly the running time grows depending on the amount of input data to it, i.e. we are interested only in the shape of the function that describes how the amount of input data affects the running time of the algorithm. The types of time complexity are named after mathematical functions that grow as quickly as this dependence, so we have a *constant* time complexity, *logarithmic* time complexity, *linear* time complexity etc. -Then we have classes of computational problems. The classes divide the problem based on how "fast" these problems can be solved. +Then we have classes of computational problems. The classes divide problems based on how "fast" they can be solved. The class P stands for **polynomial** and is defined as all problems that can be solved by an algorithm run on a **deterministic [Turing machine](turing_machine.md)** (a theoretical computer) with a *polynomial* time complexity. diff --git a/quantum_gate.md b/quantum_gate.md index d3f3134..978aa64 100644 --- a/quantum_gate.md +++ b/quantum_gate.md @@ -2,11 +2,11 @@ { Currently studying this, there may be errors. ~drummyfish } -Quantum (logic) gate is a [quantum computing](quantum.md) equivalent of a traditional [logic gate](logic_gate.md). A quantum gate takes as an input *N* [qubits](qubit.md) and transforms their states to new states. +Quantum (logic) gate is a [quantum computing](quantum.md) equivalent of a traditional [logic gate](logic_gate.md). A quantum gate takes as an input *N* [qubits](qubit.md) and transforms their states to new states (this is different from classical logical gates that may potentially have a different number of input and output values). Quantum gates are represented by [complex](complex_number.md) [matrices](matrix.md) that transform the qubit states (which can be seen as points in multidimensional space, see Bloch sphere). A gate operating on *N* qubits is represented by a *2^N*x*2^N* matrix. These matrices have to be **unitary**. Operations performed by quantum gates may be reversed, unlike those of classical logic gates. -We normally represent a single qubit state with a **column** [vector](vector.md) *|a> = a0 * |0> + a1 * |1> = [a0, a1]* (look up bra-ket notation). Multiple qubit states are represented as a [tensor product](tensor_product.md) of the individual state, e.g. *|a,b> = [a0 * b0, a0 * b1, a1 * b0, a1 * b1]*. Applying a quantum gate *G* to such a qubit vector *q* is performed by simple matrix multiplication: *G * v*. +We normally represent a single qubit state with a **column** [vector](vector.md) *|a> = a0 * |0> + a1 * |1> => [a0, a1]* (look up bra-ket notation). Multiple qubit states are represented as a [tensor product](tensor_product.md) of the individual state, e.g. *|a,b> = [a0 * b0, a0 * b1, a1 * b0, a1 * b1]*. Applying a quantum gate *G* to such a qubit vector *q* is performed by simple matrix multiplication: *G * v*. ## Basic gates diff --git a/woman.md b/woman.md index 6d98e5d..8d7f00d 100644 --- a/woman.md +++ b/woman.md @@ -1,6 +1,6 @@ # Woman -A woman (also femoid) is one of two genders of humans, the other one being [man](man.md). Women are notoriously bad at [programming](programming.mg), [math](math.md) and [technology](technology.md): in the field they usually "work" on [bullshit](bullshit.md) (and harmful) positions such as some "diversity department", [marketing](marketing.md), "HR" or [UI](ui.md)/[user experience](ux.md). If they get close to actual technology, their highest "skills" are mostly limited to casual "[coding](coding.md)" (which itself is a below-average form of [programming](programming.md)) in a baby language such as [Python](python.md) or [Javascript](javascript.md). Mostly they are just hired for quotas and make coffee for men who do the real work. +A woman (also femoid or succubus) is one of two genders of humans, the other one being [man](man.md). Women are notoriously bad at [programming](programming.mg), [math](math.md) and [technology](technology.md): in the field they usually "work" on [bullshit](bullshit.md) (and harmful) positions such as some "diversity department", [marketing](marketing.md), "HR" or [UI](ui.md)/[user experience](ux.md). If they get close to actual technology, their highest "skills" are mostly limited to casual "[coding](coding.md)" (which itself is a below-average form of [programming](programming.md)) in a baby language such as [Python](python.md) or [Javascript](javascript.md). Mostly they are just hired for quotas and make coffee for men who do the real work. But of course there exist exceptions, even though rare. The issue is women are very often involved with a cult such as the feminists who waste their effort on fighting men instead of focusing on study and creation of real technology, and on actually loving it. They don't see technology as a beautiful field of art and science, they see it as a battlefield, a political tool to be weaponized to achieve social status, revenge on society etc. They can't understand the pure joy of [programming](programming.md), the love of creation for its own sake, they think more in terms of "learning to code will get me new followers on social networks" etc. You will never find a basement dweller programmer of female gender, a hacker who is happy existing in a world of his own programs without the need for approval or external reward, a woman will never be able to understand this.