Truncate (number)

Pronunciation: /ˈtrʌŋ keɪt/ ?

A number is truncated by removing digits[1]. For example, truncating the number 14.784 to three digits yields 14.7. Note that truncating is not the same as rounding.

NumberTruncate to
digits
Truncated
Number
14.87482110
14.87482214
14.87482314.8
14.87482414.87
14.87482514.8748
14.87482614.87482
Table 1: Truncation examples

In computer languages, to truncate means to convert a floating point or decimal number to an integer[2]. The following code truncates the floating point number 3.62 to the integer 3 and prints '3'.

float num1 = 3.62;
integer num2 = trunc(num1);
print num2

The following code truncates a floating point number 7.2832 to two decimal places and prints '7.28'.

float num1 = 7.2832;
float num2 = trunc(num1 * 100.0) / 100.0;
print num2;

References

  1. truncate. Dictionary.com Unabridged.. Random House, Inc.. (Accessed: 2009-12-13). http://dictionary.reference.com/browse/Truncate.
  2. Decimal.Truncate Method. MSDN Library. Microsoft. (Accessed: 2009-12-13). http://msdn.microsoft.com/en-us/library/system.decimal.truncate.aspx.

Cite this article as:


Truncate (number). 2009-12-13. All Math Words Encyclopedia. Life is a Story Problem LLC. http://www.allmathwords.org/en/t/truncate.html.

Translations

Image Credits

Revision History


2009-12-13: Initial version. (McAdams, David.)

All Math Words Encyclopedia is a service of Life is a Story Problem LLC.
Copyright © 2005-2011 Life is a Story Problem LLC. All rights reserved.
Creative Commons License This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 License