Skip to content

The iPart() Command

Command Summary Command Syntax Calculator Compatibility Token Size
Returns the integer part of a number. iPart(value) This command works on all calculators. 1 byte
  • Press 2nd MATH to enter the MATH popup menu.
  • Press 1 to enter the Number submenu.
  • Press 4 to select iPart(.

The iPart() Command

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:
- 68k:ceiling() always rounds up to the next higher integer.
- 68k:floor() always rounds down to the next lower integer. 68k:int() does the same thing as 68k:floor().
- 68k: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 68k: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, 68k: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}
Authors: KG