The iPart( Command
IPART.GIF

Command Summary

Returns the integer part of a value.

Command Syntax

iPart(value)

Menu Location

Press:

  1. MATH to access the math menu.
  2. RIGHT to access the NUM submenu
  3. 3 to select iPart(, or use arrows.

Calculator Compatibility

TI-83/84/+/SE/CE

Token Size

1 byte

iPart(value) returns the integer part of value, and extends to complex numbers, lists, and matrices.

iPart(5.32)
               5
iPart(4/5)
               0
iPart(‾5.32)
               ‾5
iPart(‾4/5)
               0

iPart is sometimes used with it's corresponding partner fPart. While iPart trims off the part before the decimal point, fPart trims off the part after it.

The difference between iPart( and int( is subtle; while iPart( always truncates its parameters, simply removing the integer part, int( always rounds down. This means that they return the same answers for positive numbers, but int( will return an answer 1 less than iPart( for (non-integer) negative numbers. For example, iPart(-5.32) is -5, while int(-5.32) is -6.

In this case of positive values, though, the decision to use iPart( or int( is mostly a matter of preference - some people only use int( because it is shorter, some people use iPart( when there is a corresponding fPart( taken. However, see the Command Timings section.

Watch Out For Precision Issues

1/3*3→X   // X is expected to be 1
X         // Displays 1, but is actually 0.99999999999999 in memory
iPart(X)  // Displays 0
fPart(X)  // Displays 1, but is actually 0.99999999999999 in memory

Somewhat unintuitively, the code above displays the results 1, 0 and 1. This is due to the calculator storing values to 14 digits of precision, but rounding the value to 10 digits to fit on the home screen.

Tip: If you enter a value in the list editor screen, you will be able to see all 14 digits of precision. This can help you troubleshoot issues like these.

One workaround is to round the numbers prior to calling iPart() or fPart(), if you don't mind the slight loss in precision from 14 significant digits to 9 decimal places:

1/3*3→X
iPart(round(X,9))   // Displays the expected result 1
fPart(round(X,9))   // Displays the expected result 0

(The parameter 9 is not technically required here since 9 is the default, but is shown for clarity and in case you want to customize the level of precision.)

Advanced Uses

iPart(, along with fPart( and int(, can be used for integer compression.

Command Timings

The following table compares the speeds of int( and iPart(. Each command was timed over 2000 iterations to find a noticeable difference.

Format Bars Pixels Total
iPart(1 10 1 81
iPart(1.643759 10 1 81
int(1 8 7 71
int(1.643759 10 2 82

Conclusion: With 5 or fewer decimal places, you should consider using int( because of its speed, but with more decimals, iPart( remains constant to eventually beat out its counterpart.

Related Commands

See Also

.

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