How to use the TRUNC function
What is the TRUNC function?
The TRUNC function removes the fractional part of the number to an integer. Trunc stands for truncate meaning in this context removing the decimal part leaving only the integer.
1. Introduction
What is the fractional part of a number?
The fractional part of a number is the portion after the decimal point. It represents the fractional remainder when dividing a number into integer parts.
For a number x, the fractional part is denoted as: {x} The fractional part is equal to x minus the integer part of x.
For example, x = 5.921 The integer part of x is 5 (rounded down)
The fractional part is: {x} = x - integer part of x
5.921- 5 equals 0.921
What is a fractional remainder?
The fractional remainder or fractional part refers to the non-integer portion left over after dividing a number by an integer.
For example, if we divide 5 by 2: 5 / 2 = 2 with fractional remainder 1 2*2 + 1 = 5
The integer quotient is 2, but there is a remaining fractional amount of 1 left.
What is an integer?
An integer is a whole number that can be positive, negative, or zero.
What is the difference between the TRUNC function and the ROUND function?
The ROUND function rounds a number to a specified number of digits while the TRUNC function removes digits based on the precision of the truncation that you specify.
For example, TRUNC(11.9345,0) returns 11 and ROUND(11.9345,0) returns 12
How to round numbers?
Rounding is a method to simplify a number by reducing its digits while keeping its approximate value close to the original value.
There are a few common ways to round:
- Round to a set number of decimal places, rounding 2.13579 to 2 decimal places gives 2.14.
- Round up or down to the nearest integer, rounding up 2.3 gives 3. Rounding down 2.3 gives 2.
- Round to a set increment, rounding to the nearest 10 rounds 17 to 20.
- Round to significant figures, rounding 2.333 to 3 significant figures gives 2.33.
When rounding, look at the first digit after where you want to round. If it's 5 or more, round up. If less than 5, round down. Rounding makes numbers cleaner and easier to work with in many everyday situations, however, they may also cause rounding errors like rounded values can compound errors. Rounding measurements and constants may reduces precision. It is better to round numbers after performing calculations than before.
What is the difference between TRUNC function and the TRIM function?
TRUNC truncates numbers to a specified number of decimal places. For example:
TRUNC(193.459, 2) = 193.45
TRIM removes leading, trailing, and excess whitespace from text. For example:
TRIM(" Orange ") = "Orange"
What is the difference between the TRUNC function and the INT function?
The INT function extracts the integer part of a number while the TRUNC function lets you specify the precision of the truncation.
For example, TRUNC(11.2345,1) returns 11.2 and INT(11.2345) returns 11
2. Syntax
TRUNC(number, [num_digits])
number | Required. The number you want to truncate. |
[num_digits] | Optional. A number specifying the precision of the truncation. If omitted 0 (zero) is used. |
3. Example 1
These examples truncate all numbers to 0 (zero) decimals, in other words all decimal values are filtered out leaving only integers.
The first example has the source value in cell B3 and the TRUNC result is in cell C3. The value is -19 and the truncated value is also -19. The source value has no decimals.
Formula in cell C3:
The second example value is in cell B4 and the TRUNC result is in cell C4. The value is 0.9 and the truncated value is 0 (zero), the decimal is left out leaving only 0 (zero) as the result. The source value has 1 decimal.
The third value is in cell B5 and the TRUNC result is in cell C5. The value is -2.029 and the truncated value is -2, the decimals are left out leaving only -2 as the result. The source value has 3 decimals.
The fifth value is in cell B6 and the TRUNC result is in cell C6. The value is -0.9 and the truncated value is 0, the decimal is left out leaving only 0 (zero) as the result. The source value has 1 decimal.
The fourth value is in cell B7 and the TRUNC result is in cell C7. The value is 39.5 and the truncated value is 39, the decimal is left out leaving only 39 as the result. The source value has 1 decimal.
The sixth value is in cell B8 and the TRUNC result is in cell C8. The value is 21.2 and the truncated value is 21, the decimal is left out leaving only 0 (zero) as the result. The source value has 1 decimal.
The seventh value is in cell B9 and the TRUNC result is in cell C9. The value is 0.0035 and the truncated value is 0, the decimals are left out leaving only 0 (zero) as the result. The source value has 4 decimals.
The eigth value is in cell B10 and the TRUNC result is in cell C10. The value is 3.6 and the truncated value is 3, the decimal is left out leaving only 3 as the result. The source value has 1 decimal.
4. Example 2
A vehicle drives from location A to location B. The journey takes 47 minutes, and the car maintains an average speed of 62 miles per hour. What is the distance between points A and B? Truncate the result to one decimal?
What we know:
- The distance is equal to speed x time.
- Speed = 60 miles per hour
- Time = 47 minutes
Formula in cell C22:
The formula in cell C22 returns 48.5 miles which represents the distance between point A to point B based on a constant speed of 60 miles / hour over a duration of 47 minutes.
Lets calculate this manually:
- Convert time from minutes to hours. 47 minutes / 60 minutes = 47/60 hours
- Multiply duration by speed. 47/60 hours * 62 miles/hour = 47*62/60 miles = 48.5666666666667 miles.
- Truncate to one decimal: 48.5666666666667 = 48.5 miles.
5. Example 3
An object above ground has initial velocity of 2 feet/s. The final velocity right before ground impact is 4 feet/s. The time it takes to reach the ground is 1.3 seconds. What is the acceleration? Truncate the answer to 2 decimals.
What we know:
- Basic acceleration formula: a = (v - u) / t
a = acceleration, v = final velocity, u = initial velocity, t = time - Acceleration: Unknown
- Initial velocity: 2 feet/s
- Final velocity: 4 feet/s
- Time: 1.3 seconds
Formula in cell C23:
The formula in cell C22 returns 1.53 feet/s2 which represents the acceleration with an initial velocity of 2 feet/s and a final velocity of 4 feet/s based on a duration of 1.3 seconds.
Lets calculate this manually:
- Final velocity minus the initial velocity: 4-2 = 2
- Ratio between the velocity difference and the duration: 2/1.3 = 1.53846153846154
- Truncate the result to two decimals: 1.53846153846154 = 1.53 feet/s2
This result is equal to the value in cell C23.
Functions in 'Math and trigonometry' category
The TRUNC function function is one of 62 functions in the 'Math and trigonometry' category.
How to comment
How to add a formula to your comment
<code>Insert your formula here.</code>
Convert less than and larger than signs
Use html character entities instead of less than and larger than signs.
< becomes < and > becomes >
How to add VBA code to your comment
[vb 1="vbnet" language=","]
Put your VBA code here.
[/vb]
How to add a picture to your comment:
Upload picture to postimage.org or imgur
Paste image link to your comment.
Contact Oscar
You can contact me through this contact form