The remain() 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.

remain.png

Command Summary

Returns the remainder of a division.

Command Syntax

remain(dividend,divisor)

Menu Location

  • Press 2nd MATH to enter the math popup menu.
  • Press 1 to enter the Number submenu.
  • Press A to select remain(.

Calculator Compatibility

This command works on all calculators.

Token Size

1 byte

The remain() command returns the remainder of a division: remain(A,B) is calculated as A-B*intDiv(A,B) which in turn is equivalent to A-B*iPart(A/B). Although this operation is most useful for dividing whole numbers, this definition works for any number, whole or decimal, real or complex. Additionally, remain(X,0) is defined as X.

The related mod() command returns the same results for positive numbers, however, they disagree when negative integers enter the mix. The result of mod() is defined just as remain(), but with int() instead of iPart(). This means that remain() gives a negative answer if the dividend is negative, and mod() gives a negative answer if the divisor is negative.

:remain(125,3)
           2
:remain(-125,3)
           -2
:remain(2*i+1,i+1)
           i

The remain() command also works for lists and matrices. Used with a list or matrix and a number, remain() is applied to the number paired with every element of the list or matrix. Used with two lists or two matrices, which must match in size, remain() is applied to matching elements of the list or matrix.

Advanced Uses

Use intDiv() and remain() for the quotient and remainder results of long division, respectively.

Error Conditions

240 - Dimension mismatch happens when two list or matrix arguments don't match in size.

Related Commands

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