maTeionE best viewed with NetSurf 
My programs  Games  Other programs  
GNU/Linux  Computers & programming  Music & movies  
Other topics  What's new + README  Contact  
  
History
Computers
Computer graphics
Programming
Numbers & logic

Updated 20230408 Numbers; logical and arithmetic operations Numbers Although humans and many other animals have a natural ability to distinguish between groups with different numbers of objects, the symbolic representation of numbers is an invention which was developed within human civilisation . when University of Miami associate professor Caleb Everett and other anthropologists
worked with the indigenous Amazonian people known as the Pirahã, they realized the members of the tribe had
no word used consistently to identify any quantity, not even one. The specialized form of knowing needed for literacy and numeracy skills is called symbolic representation. This develops gradually and is not evident until children are about 6 years old. The most efficient system developed so far for representing numbers uses digits and number bases. In a base, a number is represented as a string of symbols called digits, like 123. The base, which is named according to the number of distinct symbols (digits) used, can also be specified: 123_{10}. Base 2, which uses 2 symbols, 0 and 1, is currently used in most computers, but ENIAC and Charles Babbage's Analytical Engine , for instance, used base 10. Example:123_{10} = 1·10^{2}+2·10^{1}+3·10^{0} = = 1·2^{6}+1·2^{5}+1·2^{4}+1·2^{3}+0·2^{2}+1·2^{1}+1·2^{0} = 1111011_{2} Elements of formal logic Formal logic is the science of deductively valid arguments . An argument is a series of propositions in which one proposition, called the conclusion, is presented as following from another set of propositions, called the premises. A proposition is a statement which can be either true or false. All birds can fly, for instance, is a false statement. The statement This statement is false, which refers only to itself, however, can not be true nor false. This does not represent a problem, because the statement refers only to itself and is thus never relevant in any situation, so there's no reason why anyone should think about it. An argument is deductively valid if and only if a false conclusion can not be obtained when all the premises are true. With a valid argument and at least one false premise, the conclusion can be false, but also true. The fundamental principle of logic says that if an argument is valid, then every argument with the same form is also valid, hence the term formal logic. True and false are considered truth values and are usually associated with numbers 1 and 0, respectively. Propositions or truth values can be connected by logical operators, some of which are shown in the following table, where A and B are the inputs and Q is the output:
Other logic gates:
Arithmetic operations The basic arithmetic operations which can be performed on numbers are addition, subtraction, multiplication and division. The simplest operation is adding two 1bit positive numbers (in base 2), for which a device called half adder can be used. As can be seen below, it is composed of 2 logic gates: xor and and.
MD5: 7ced0ef2f6c80c954d325b0db66f792c A and B are the input values and can be equal to 0 or 1. Storing the result requires 2 bits, because if A=B=1, then A+B=1+1=2_{10}=10_{2}, in which case C_{o}=1 and S=0. C_{o} is called carry bit because when nbit numbers are added, this bit is carried to the next adder, which has to be a full adder with 3 inputs, as shown below.
A full adder is composed of 2 half adders and an or gate. By connecting n full adders, an nbit ripple carry adder can be formed, which can be used for adding two nbit numbers, in which case the result will require n+1 bits for storage.
If, for instance, A=5_{10}=101_{2} and B=3_{10}=11_{2}, then the 3bit adder above produces the following results:
The bits of the final result are C_{o,2}=1, S_{2}=0, S_{1}=0 and S_{0}=0, which means that: A+B=5_{10}+3_{10}=101_{2}+011_{2}=1000_{2}=8_{10} Larger numbers can be added by repeating the operation. For instance, 2 numbers composed of 6 bits can be added by first adding the rightmost (least significant) 3 bits and then the other 3, while considering C_{i,0} equal to C_{o,2} from the previous operation. For representing nbit signed binary numbers, 3 methods can be used:
3_{10}+(3)_{10}=011_{2}+101_{2}=1000_{2} In base 2 the calculation looks the same as the previous one above (5+3), but this time the numbers are signed and after discarding the leftmost bit, the correct result, i.e. 0, is obtained. 

 