Truncation: Difference between revisions
→Causes of truncation: Not relevant to this subject, the disambiguation page points at the correct one |
No edit summary |
||
Line 8: | Line 8: | ||
Truncation of positive real numbers can be done using the [[floor function]]. Given a number <math>x \in \mathbb{R}_+</math> to be truncated and <math>n \in \mathbb{N}_0</math>, the number of elements to be kept behind the decimal point, the truncated value of x is |
Truncation of positive real numbers can be done using the [[floor function]]. Given a number <math>x \in \mathbb{R}_+</math> to be truncated and <math>n \in \mathbb{N}_0</math>, the number of elements to be kept behind the decimal point, the truncated value of x is |
||
:<math>\operatorname{trunc}(x,n) = \frac{\lfloor 10^n \cdot x \rfloor}{10^n}.</math> |
:<math>\operatorname{trunc}(x,n) = \frac{\lfloor 10^n \cdot x \rfloor}{10^n}.</math> |
||
''Where the part in the dividend is read as "the Integer part of" by using the operand "[ ]" (see [[Floor_and_ceiling_functions#Typesetting|typesetting of floor and ceiling functions]])'' |
|||
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. For a given number <math>x \in \mathbb{R}_-</math>, the function |
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. For a given number <math>x \in \mathbb{R}_-</math>, the function |
Revision as of 23:55, 14 July 2021
In mathematics and computer science, truncation is limiting the number of digits right of the decimal point.
Truncation and floor function
Truncation of positive real numbers can be done using the floor function. Given a number to be truncated and , the number of elements to be kept behind the decimal point, the truncated value of x is
Where the part in the dividend is read as "the Integer part of" by using the operand "[ ]" (see typesetting of floor and ceiling functions)
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. For a given number , the function
is used instead.
Causes of truncation
With computers, truncation can occur when a decimal number is typecast as an integer; it is truncated to zero decimal digits because integers cannot store non-integer real numbers.
In algebra
An analogue of truncation can be applied to polynomials. In this case, the truncation of a polynomial P to degree n can be defined as the sum of all terms of P of degree n or less. Polynomial truncations arise in the study of Taylor polynomials, for example.[1]
See also
- Arithmetic precision
- Floor function
- Quantization (signal processing)
- Precision (computer science)
- Truncation (statistics)
References
- ^ Spivak, Michael (2008). Calculus (4th ed.). p. 434. ISBN 978-0-914098-91-1.
External links
- Wall paper applet that visualizes errors due to finite precision