Truncation
Encyclopedia
In mathematics
Mathematics
Mathematics is the study of quantity, space, structure, and change. Mathematicians seek out patterns and formulate new conjectures. Mathematicians resolve the truth or falsity of conjectures by mathematical proofs, which are arguments sufficient to convince other mathematicians of their validity...

 and computer science
Computer science
Computer science or computing science is the study of the theoretical foundations of information and computation and of practical techniques for their implementation and application in computer systems...

, truncation is the term for limiting the number of digit
Numerical digit
A digit is a symbol used in combinations to represent numbers in positional numeral systems. The name "digit" comes from the fact that the 10 digits of the hands correspond to the 10 symbols of the common base 10 number system, i.e...

s right of the decimal point, by discarding the least significant ones.

For example, consider the real number
Real number
In mathematics, a real number is a value that represents a quantity along a continuum, such as -5 , 4/3 , 8.6 , √2 and π...

s
5.6341432543653654
32.438191288
−6.3444444444444


To truncate these numbers to 4 decimal digits, we only consider the 4 digits to the right of the decimal point.

The result would be:
5.6341
32.4381
−6.3444


Note that in some cases, truncating would yield the same result as rounding
Rounding
Rounding a numerical value means replacing it by another value that is approximately equal but has a shorter, simpler, or more explicit representation; for example, replacing $23.4476 with $23.45, or the fraction 312/937 with 1/3, or the expression √2 with 1.414.Rounding is often done on purpose to...

, but truncation does not round up or round down the digits; it merely cuts off at the specified digit. The truncation error
Error
The word error entails different meanings and usages relative to how it is conceptually applied. The concrete meaning of the Latin word "error" is "wandering" or "straying". Unlike an illusion, an error or a mistake can sometimes be dispelled through knowledge...

 can be twice the maximum error in rounding.

Truncation and floor function

Truncation of positive real numbers can be done using the floor function
Floor function
In mathematics and computer science, the floor and ceiling functions map a real number to the largest previous or the smallest following integer, respectively...

. Given a number to be truncated and , the number of elements to be kept behind the decimal point, the truncated value of x is

However, for negative numbers truncation does not round in the same direction as the floor function: truncation always rounds toward zero, the floor function rounds towards negative infinity.

Causes of truncation

With computers, truncation can occur when a decimal number is typecast
Type conversion
In computer science, type conversion, typecasting, and coercion are different ways of, implicitly or explicitly, changing an entity of one data type into another. This is done to take advantage of certain features of type hierarchies or type representations...

 as an integer
Integer
The integers are formed by the natural numbers together with the negatives of the non-zero natural numbers .They are known as Positive and Negative Integers respectively...

; it is truncated to zero decimal digits because integers cannot store real numbers (that are not themselves integers). Truncation may also occur when a number cannot be fully represented due to memory limitations.

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK