PC.net
HomeHome : Glossary : Definition
ShareShare

Truncate

Truncate Image

To truncate something is to shorten it, or cut part of it off. In computer science, the term is often used in reference to data types or variables, such as floating point numbers and strings.

For example, a function may truncate the decimal portion of a floating point number to make it an integer. If the number 3.875 is truncated, it becomes 3. Note that this is different than if the number had been rounded to the nearest integer, which would be 4. Strings may also be truncated, which can be useful if a string exceeds the maximum character limit for a certain application.

Several programming languages use the function trunc() to truncate a variable. PHP uses strlen() to truncate a string to a set limit of characters.

Published: 2007

Definition from the PC Glossary
https://pc.net/glossary/truncate
space