The iPart() Command

We're glad you came by, but you might find what you're looking for elsewhere.

TI-Basic Developer is not the site it once was. While its information on commands and other calculator features remains almost second-to-none, its forum, archives, and even hosting service, Wikidot, have been decaying for years. The calculator community would love to see what you're working on, or help you in your next coding adventure, but TI-Basic Developer is no longer the place to do it.

Instead, you should head over to Cemetech (primarily American) or TI-Planet (primarily international). Both are active, well-established forums with their own archives, chatrooms, reference material, and abundant coding tools and resources. We'll see you there, we hope.

ipart.png

Command Summary

Returns the integer part of a number.

Command Syntax

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(.

Calculator Compatibility

This command works on all calculators.

Token Size

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}

Related Commands

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-Noncommercial 2.5 License.