ThisCalculator

Everyday

Get Integer Part of a Number: Methods & Examples

Updated · Standard formula, shown below

To get the integer part of a number, you remove everything after the decimal point and keep only the whole-number portion. For positive numbers, this is the same as rounding down (floor); for negative numbers, it is the same as rounding toward zero (truncation). This article explains the difference between truncation, floor, and rounding, shows formulas for calculators and spreadsheets, and covers common pitfalls.

What “Integer Part” Means

The integer part of a number is the portion that lies to the left of the decimal point. For example, the integer part of 7.83 is 7, and the integer part of 12.0 is 12. The fractional part is what remains: 0.83 in the first case, and 0 in the second.

This definition is straightforward for positive numbers, but it becomes ambiguous for negatives. Consider -3.7. One common interpretation says the integer part is -3 (truncation, moving toward zero). Another says it is -4 (floor, moving down to the next lower integer). Both are used in different programming languages and mathematical contexts, so always check which convention your tool uses.

Truncation vs. Floor vs. Round

These three operations are often confused, but they give different results for negative numbers and for values exactly halfway between integers.

  • Truncation (INT in many languages): removes the decimal part entirely. 3.9 → 3, -3.9 → -3. It always moves toward zero.
  • Floor (FLOOR): moves to the next lower integer. 3.9 → 3, -3.9 → -4. It always moves down the number line.
  • Round (ROUND): goes to the nearest integer. 3.4 → 3, 3.6 → 4, 3.5 → 4 (with ties typically rounded up in most systems).

For positive numbers, truncation and floor are identical. For negative numbers, they differ by exactly 1 whenever the number is not already an integer. If you need the integer part of a negative number in a spreadsheet, use TRUNC for truncation or FLOOR for the mathematical floor, depending on your goal.

Formulas for Calculators and Spreadsheets

In most spreadsheet software, the function INT returns the floor, not truncation. That means =INT(-2.3) gives -3. If you want truncation, use TRUNC or ROUNDDOWN. In programming languages, the behavior varies: Python’s int() truncates toward zero, while math.floor() gives the floor. JavaScript’s Math.trunc() truncates, and Math.floor() floors.

If you only have basic arithmetic, you can compute the integer part with a formula. For truncation toward zero, use:

IF x ≥ 0: FLOOR(x)   IF x < 0: CEILING(x)

Or in a single expression using sign and absolute value:

SIGN(x) * FLOOR(ABS(x))

This works because ABS makes the number positive, FLOOR rounds down, and SIGN restores the original sign, which effectively truncates toward zero.

Worked Example

Take the number 17.92. The integer part is 17 because the decimal portion is 0.92, which is removed. If the number were -17.92, truncation gives -17, while floor gives -18. For a calculator that returns the integer part, 17.92 should display 17 and -17.92 should display -17 if it truncates, or -18 if it floors. Always test with a negative number to see which convention is implemented.

Common Mistakes and Misconceptions

A frequent error is assuming that the integer part of a negative number is the same as its absolute value. For -4.7, some people write -4, but if you are using the floor convention, the correct answer is -5. Another mistake is confusing the integer part with rounding. The integer part of 9.99 is 9, not 10, even though 9.99 rounds to 10. Also, be aware that some calculators have a dedicated “INT” key that may truncate or floor depending on the manufacturer; read the manual or test with -1.5 to verify.

Finally, note that the integer part of a number is always an integer, but it is not necessarily the same as the result of removing the decimal point. Removing the decimal point from 12.34 gives 1234, which is not the integer part. The integer part is just 12.

Practical Uses

Extracting the integer part is useful in many real-world situations:

  • Splitting currency amounts into whole units and cents.
  • Converting minutes to hours and minutes (integer part gives hours).
  • Indexing into arrays or lists where positions must be whole numbers.
  • Formatting measurements where only whole units are displayed.

For example, if you have 145 minutes and want to express it as hours and minutes, the integer part of 145/60 is 2 hours, and the remainder is 25 minutes. This works because 2 × 60 = 120, and 145 − 120 = 25.

Frequently Asked Questions

Is the integer part the same as the floor? Not always. For positive numbers, yes. For negative numbers, floor is one less than truncation when the number is not an integer. For example, floor(-2.1) = -3, but the integer part by truncation is -2.

How do I get the integer part in Excel? Use =TRUNC(A1) for truncation toward zero, or =INT(A1) for the floor. For positive numbers, both return the same value. For negative numbers, TRUNC gives -2 for -2.7, while INT gives -3.

What is the difference between INT and TRUNC in SQL? In many SQL dialects, INT returns the floor (e.g., INT(-2.7) = -3), while TRUNC truncates toward zero (TRUNC(-2.7) = -2). Check your database documentation, as implementations vary.

Does the integer part of a negative number include the minus sign? Yes. The integer part of -5.8 is -5 if you truncate, or -6 if you floor. The minus sign is preserved because the result is still a negative integer.

Can the integer part be zero? Yes. For any number between -1 and 1 (excluding exactly 1 or -1), the integer part is 0. For example, 0.45 → 0, and -0.45 → 0 under truncation, but -0.45 → -1 under floor.

Why does my calculator show -1 for the integer part of -0.5? Some calculators use the floor convention, so -0.5 floors to -1. Others truncate and show 0. This is a known difference; check your device’s manual to know which one it uses.

Related

Method: the standard formula for this calculation, rounded as each result states. See how the calculators work or report an error.