User:Phlsph7/Integer arithmetic

From Wikipedia, the free encyclopedia

Integer arithmetic[edit]

Integer arithmetic is the branch of arithmetic that deals with the manipulation of positive and negative whole numbers. The set of integers is represented by the symbol and can be expressed as {..., -3, -2, -1, 0, 1, 2, 3, ...}.[1][2][3]

Simple one-digit operations can be performed by following or memorizing a table that presents the results of all possible combinations, like an addition table or a multiplication table. Other common methods are verbal counting and finger-counting.[4][5][6]

Addition table
+ 0 1 2 3 4 ...
0 0 1 2 3 4 ...
1 1 2 3 4 5 ...
2 2 3 4 5 6 ...
3 3 4 5 6 7 ...
4 4 5 6 7 8 ...
... ... ... ... ... ... ...
Multiplication table
× 0 1 2 3 4 ...
0 0 0 0 0 0 ...
1 0 1 2 3 4 ...
2 0 2 4 6 8 ...
3 0 3 6 9 12 ...
4 0 4 8 12 16 ...
... ... ... ... ... ... ...
Diagram of addition with carry
Example of addition with carry. The black numbers are the addends, the green number is the carry, and the blue number is the sum.

For operations on numbers with more than one digit, different techniques can be employed to calculate the result by using several one-digit operations in a row. For example, in the method addition with carries, the two numbers are written one above the other. Starting from the rightmost digit, each pair of digits is added together. The rightmost digit of the sum is written below them. If the sum is a two-digit number then the leftmost digit, called the "carry", is added to the next pair of digits to the left. This process is repeated until all digits have been added.[7][8] Other methods used for integer additions are the number line method, the partial sum method, and the compensation method.[9][10] A similar technique is used for subtraction: it also starts with the rightmost digit and uses a "borrow" or a negative carry for the column on the left if the result of the one-digit subtraction is negative.[11]

Diagram of long multiplication
Example of long multiplication. The black numbers are the multiplicand and the multiplier. The green numbers are intermediary products gained by multiplying the multiplicant with only one digit of the multiplier. The blue number is the total product calculated by adding the intermediary products.

A basic technique of integer multiplication uses repeated addition. For example, the product of 3 × 4 can be calculated as 3 + 3 + 3 + 3.[12] A common technique for multiplication with larger numbers is called long multiplication. This method starts by writing the multiplicand above the multiplier. The calculation begins by multiplying the multiplicand only with the rightmost digit of the multiplier and writing the result below, starting in the rightmost column. The same is done for each digit of the multiplier and the result in each case is shifted one position to the left. As a final step, all the individual products are added to arrive at the total product of the two multi-digit numbers.[13][14] Other techniques used for multiplication are the grid method and the lattice method.[15] Computer science is interested in multiplication algorithms with a low computational complexity to be able to efficiently multiply very large integers, such as the Karatsuba algorithm, the Schönhage-Strassen algorithm, and the Toom-Cook algorithm.[16][17] A common technique used for division is called long division. Other methods include short division and chunking.[18]

Integer arithmetic is not closed under division. This means that when dividing one integer by another integer, the result is not always an integer. For example, 7 divided by 2 is not a whole number but 3.5.[19] One way to ensure that the result is an integer is to round the result to a whole number. However, this method leads to inaccuracies as the original value is altered.[20] Another method is to perform the division only partially and retain the remainder. For example, 7 divided by 2 is 3 with a remainder of 1. These difficulties are avoided by rational arithmetic, which allows for the exact representation of fractions.[21]

A simple method to calculate exponentiation is by repeated multiplication. For example, the exponentiation of 34 can be calculated as 3 × 3 × 3 × 3.[22] A more efficient technique used for large exponents is exponentiation by squaring. It breaks down the calculation into a number of squaring operations. For example, the exponentiation 365 can be written as ((((32)2)2)2)2)2 × 3. By taking advantage of repeated squaring operations, only 7 individual operations are needed rather than the 64 operations required for regular repeated multiplication.[23][24] Methods to calculate logarithms include the Taylor series and continued fractions.[25][26] Integer arithmetic is not closed under logarithm and under exponentiation with negative exponents, meaning that the result of these operations is not always an integer.[27][25]

References[edit]