Skip to content
Property Value
Hex Value $BA
Categories
Localizations
  • FR: partDéc(

fPart(

Overview

Returns the fractional part or parts of a real or complex number, expression, list, or matrix.

Availability: Token available everywhere.

Syntax

fPart(value)

Arguments

NameTypeOptional
value

Location

math, NUM, 4:fPart(


Description

fPart(value) returns the fractional part of value, be it a variable, list, or matrix.

fPart(5.32)
             .32
fPart(4/5)
              .8
fPart(‾5.32)
             ‾.32
fPart(‾4/5)
              ‾.8

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

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. Because of this, fPart() can appear to return values of 1 or -1.

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

Modulus

fPart( is an easy way to find A mod B (the positive remainder when A is divided by B).

B(A<0)+iPart(BfPart(A/B))

If A is guaranteed to be positive, the following shorter code can be used, omitting B(A<0):

iPart(BfPart(A/B))

Detect Whole Numbers

The easiest way to check if a number is a whole number is not(fPart(X:

If not(fPart(X:Then
  // X is an integer
Else
  // X is not an integer
End

This can be used, for example, to check if a number is divisible by another: if X is divisible by N, then X/N is a whole number. This is useful for finding the factors of a number.

Compression

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

See Also


Source: parts of this page were written by the following TI|BD contributors: burr, CloudVariable, DarkerLine, ePIi, GoVegan, kg583.

History

Calculator OS Version Description
TI-82 1.0 fPart added
TI-83 0.01013 Renamed fPart to fPart(
Authors: Adrien Bertrand