An Example Of Working On The Estack - Texas Instruments TI-89 Developer's Manual

Graphing calculator
Hide thumbs Also See for TI-89:
Table of Contents

Advertisement

Chapter 15: Expressions and The Expression Stack
top expression with its reciprocal; and replace_top_with_post_simplified
replaces the top expression (assumed to be internal form) with its external
tokenized form.
Routines whose names begin with "is_" are used to get information about
expressions. They have no effect on the contents of the estack or the
expressions they inspect. However, sometimes they must perform some
temporary computation to determine the requested information. Under these
circumstances the estack may temporarily grow. For example, is_negative tests
whether an expression is negative; is_real tests whether an expression is real;
and, is_equivalent_to tests whether one expression is equivalent to another.
Routines whose names begin with "index_" or end with "_index" are used to
locate expressions or subexpressions. They also have no effect on the estack or
expressions. They simply return the EStackIndex of the located expression. For
example, next_expression_index returns the index of the next expression
below the expression pointed to by its input argument; lead_factor_index
returns the index of the first factor of the multiplication pointed to by its input
argument; and, remaining_factors_index returns the index of the remaining
factors following the first factor of the multiplication pointed to by its input
argument.
See Appendix A: System Routines for a complete list of the system routines
that perform estack operations.
15.6.

An Example of Working on the EStack

This section takes a simple C language programming example and works
through alternative implementations to show how the same operations can be
done using estack operations. We begin with a C language implementation of a
function to compute the future value of a lump sum present value given the periodic
interest rate and the number of periods. The formula for this computation is
future_value = present_value * ( interest_rate + 1) ^ number_of_periods.
C programming language example:
/* This function takes three BCD16 arguments.
pv = present value
ir = interest rate
np = number of periods
The function returns future value fv as a BCD16.
*/
BCD16 fv (BCD16 pv, BCD16 ir, BCD16 np)
{
return pv * pow(ir + 1.0, np);
}
TI-89 / TI-92 Plus Developer Guide
Not for Distribution
175
Beta Version January 26, 2001

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Ti-92 plusTi-92 plus

Table of Contents