Returns the integer part of a number.
iPart(value)
Menu Location
- Press 2nd MATH to enter the MATH popup menu.
- Press 1 to enter the Number submenu.
- Press 4 to select iPart(.
This command works on all calculators.
1 byte
The iPart() command returns the integer part of a number (removing all the digits after the decimal). Another way of thinking about it is it rounds a number towards 0: positive numbers get rounded down to an integer, and negative numbers get rounded up to an integer.
There are several other rounding commands available, which work in subtly different ways:
- ceiling() always rounds up to the next higher integer.
- floor() always rounds down to the next lower integer. int() does the same thing as floor().
- round() rounds to any given place value, including to an integer; it rounds up or down, whichever is nearest.
However, iPart() is the only one that has a counterpart fPart() which returns the fractional part of a number. This follows the rule that iPart(x)+fPart(x) always equals x.
Using iPart() on the result of a division — iPart(x/y) — is useful so often that there's a specific command, intDiv(), for doing so.
iPart() can also be applied to complex numbers, lists, and matrices, rounding everything that there is to round in each of them.
:iPart(3)
3
:iPart({-π,π})
{-3 3}