TRUNC Function (OpenOffice Calc)
The TRUNC function in OpenOffice Calc removes the fractional part of a number by truncating toward zero. Learn syntax, behavior with negative numbers, examples, and best practices.
Compatibility
βΎ| Excel | β |
| Gnumeric | β |
| Google_sheets | β |
| Libreoffice | β |
| Numbers | β |
| Onlyoffice | β |
| Openoffice | β |
| Wps | β |
| Zoho | β |
What the TRUNC Function Does βΎ
- Removes the decimal portion of a number
- Always rounds toward zero
- Works with positive and negative numbers
- Useful for ID extraction, integer math, and formatting logic
- Works across sheets
TRUNC is ideal when you need clean integer extraction without directional rounding.
Syntax βΎ
TRUNC(number)
Arguments:
- number β Any numeric value or formula result
TRUNC is different from INT:
- TRUNC β toward zero
- INT β toward negative infinity
Behavior With Positive and Negative Numbers βΎ
| Input | TRUNC Result | Explanation |
|---|---|---|
| 7.9 | 7 | Fraction removed |
| 7.1 | 7 | Fraction removed |
| -7.1 | -7 | Toward zero |
| -7.9 | -7 | Toward zero |
This makes TRUNC safer than INT when working with negative values.
Basic Examples βΎ
Remove decimals from a number
=TRUNC(7.9)
Result: 7
Truncate a negative number
=TRUNC(-7.9)
Result: -7
Truncate a formula result
=TRUNC(A1 / B1)
TRUNC with cell reference
=TRUNC(A1)
Advanced Examples βΎ
Extract integer part of a division
=TRUNC(A1 / 12)
Useful for converting months to years, items to boxes, etc.
TRUNC for ID or code extraction
=TRUNC(A1)
Useful when numeric IDs contain decimals due to import issues.
TRUNC for date/time calculations
Extract whole days from a datetime:
=TRUNC(A1)
TRUNC across sheets
=TRUNC(Sheet1.A1)
TRUNC for pagination logic
Page number from row:
=TRUNC((ROW()-1) / 50) + 1
TRUNC for random integer ranges
=TRUNC(RAND() * 100)
Returns 0β99.
TRUNC with optional decimal places (LibreOffice only)
LibreOffice supports:
TRUNC(number; digits)
OpenOffice Calc does not support the second argument.
Comparison: TRUNC vs INT vs FLOOR βΎ
| Function | Rounds Toward | Example: -7.1 | Notes |
|---|---|---|---|
| TRUNC | 0 | -7 | Removes decimals |
| INT | ββ | -8 | Always down |
| FLOOR | ββ | -8 | Down to a multiple |
TRUNC is the most neutral of the three.
Common Errors and Fixes βΎ
TRUNC returns Err:502 (Invalid argument)
Occurs when:
- Input is text
- Input is empty
- A malformed reference is used
TRUNC returns unexpected values
Possible causes:
- Confusing TRUNC with INT
- Text numbers not converted to numeric
- Hidden spaces in cells
TRUNC ignores values you expected it to include
TRUNC ignores:
- Text numbers (
"123") - Empty cells
- Logical values
- Errors
TRUNC includes values you expected it to ignore
TRUNC includes:
- Dates
- Times
- Numeric results of formulas
Err:508 β Missing parenthesis
Usually caused by:
- Missing
) - Using commas instead of semicolons
Best Practices βΎ
- Use TRUNC when you need neutral truncation
- Use INT when rounding must go downward
- Use FLOOR when rounding to a multiple
- Convert imported text numbers to real numbers
- Use named ranges for cleaner formulas