Truncate

To truncate something is to shorten it by cutting off part of it. In computing, truncation may remove digits from a number, characters from a string, or data that exceeds a specified size or limit.

For example, truncating the floating point number 2.75 to an integer removes its fractional portion, producing 2. Truncation is different than rounding, so 3.875 becomes 3 rather than 4. It also moves negative numbers toward zero: truncating -2.75 produces -2, not -3.

Strings may be truncated when they exceed a character limit. For example, a program may truncate a user's text input if it contains too many characters. For example, if a user enters 300 characters when only 250 are allowed, the program will cut off the last 30 characters when storing the data. (A better solution would be to limit the input field to 250 characters to avoid unexpected truncation.)

Applications also visually truncate filenames and labels when they are too long to display in a small area. For example, an app might shorten "This document has a really long filename.txt" to "This document has a..." when displaying it in a narrow column. The ellipsis indicates that it has omitted part of the original text, although the ellipsis itself is not part of the truncation.

Truncation in Computer Programming

Many programming languages provide a function for truncating numbers. For instance, Python uses math.trunc(), while JavaScript uses Math.trunc(). Both remove the fractional part of a number without rounding it. For example, a video game developer may truncate the value of a player's level when displaying it on a screen. If the player's level in the game is 6.92, it will display 6 on the screen. Once the value hits 7.0 or higher, it will display 7.

Truncating a string involves extracting the characters within a specified range. For example, the PHP function substr($text, 0, 6) starts at the first character, grabs exactly six characters from the string $text. The mb_substr() can safely limit multibyte-encoded text by the amount of storage the string requires. Both methods are useful for ensuring strings are small enough to store in a database or other location with size limitations.

NOTE: Truncation permanently discards the omitted portion of the data unless the program retains the original value elsewhere.

Updated August 4, 2026 by Per C.

quizTest Your Knowledge

An LAN is a ____ Area Network?

A
Limited
0%
B
Locked
0%
C
Local
0%
D
Loose
0%
Correct! Incorrect!     View the LAN definition.
More Quizzes →

The Tech Terms Computer Dictionary

The definition of Truncate on this page is an original definition written by the authors of TechTerms.com. If you would like to reference this page or cite this definition, please use the green citation bar directly below the definition.

Our goal is to explain computer terminology in a way that is easy to understand. We strive for accuracy and simplicity with every definition we publish. If you have feedback about this definition or would like to suggest a new technical term, please contact us.

The Tech Terms Newsletter

Improve your technical knowledge with our daily or weekly newsletter! Subscribe today and get new terms and quizzes delivered to your inbox.

Sign up for the free TechTerms Newsletter

How often would you like to receive an email?

You can unsubscribe or change your frequency setting at any time using the links available in each email. Questions? Please contact us.