HP 15c Manual
Here you can view all the pages of manual HP 15c Manual. The HP manuals for Calculator are available online for free. You can easily download all the documents as PDF.
Page 91
Section 8: Program Branching and Controls 91 of this loop can be controlled by a conditional branch, an ¦ instruction (written into the loop), or simply by pressing any key during execution (which stops the program). Conditional Tests Another way to alter the sequence of program execution is by a conditional test, a true/false test which compares the number in the X-register either to zero or to the number in the Y-register. The HP-15C provides 12...
Page 92
92 Section 8: Program Branching and Controls Following a conditional test, program execution follows the Do if True Rule: it proceeds sequentially if the condition is true, and it skips one instruction if the condition is false. A t instruction is often placed right after a conditional test, making it a conditional branch; that is, the t branch is executed only if the test condition is met. Flags Another conditional test for programming is a flag test. A...
Page 93
Section 8: Program Branching and Controls 93 Examples Example: Branching and Looping A radiobiology lab wants to predict the diminishing radioactivity of a test amount of 131I, a radioisotope. Write a program to figure the radioactivity at 3-day intervals until a given limit is reached. The formula for Nt, the amount of radioisotope remaining after t days, is Nt = No (2-t/k), where k = 8 days, the half-life of 131I, and N0 is the initial amount. The following...
Page 94
94 Section 8: Program Branching and Controls Keystrokes Display l * 1 010-45,20, 1 Recall multiplication with the contents of R1 (N0), yielding Nt, the mci of 131I remaining after t days ´© 011- 42 31 Pauses to display Nt. l 2 012- 45 2 Recalls limit value to X-register. | T 9 013-43,30, 9 x ≥ y ? Tests whether limit value (in X) meets or exceeds Nt (in Y). | n 014- 43 32 If so, program ends. 3 015- 3 If not, program continues. O+ 0 016-44,40, 0 Adds 3 days to t in R0. tA...
Page 95
Section 8: Program Branching and Controls 95 Example: Flags Calculations on debts or investments can be calculated in two ways: for payments made in advance (at the beginning of a given period) and for payments made in arrears (at the end of a given period). If you write a program to calculate the value (or ―present value‖) of a debt or investment with periodic interest and periodic payments, you can use a flag as a status indicator...
Page 96
96 Section 8: Program Branching and Controls Keystrokes Display | ¥ 000- Program mode. ´ bB 001-42,21,12 Start at B if payments to be made at the beginning. | 0 002-43, 5, 0 Flag 0 clear (false); indicates advance payments. t 1 003- 22 1 Go to main routine. ´ b E 004-42,21,15 Start at E if payments to be made at the end. | F 0 005-43, 4, 0 Flag 0 set (true); indicates payment in arrears. ´ b 1 006-42,21, 1 Routine 1 (main routine). O1 007- 44 1 Stores i (from X-register). 1 008-...
Page 97
Section 8: Program Branching and Controls 97 Now run the program to find the total amount needed in an account from which you want to take $250/month for 48 months. Enter the periodic interest rate as a decimal fraction, that is, 0.005 per month. First find the sum needed if payments will be made at the beginning of the month (payments in advance), then calculate the sum needed if payments will be made at the end of the month (in...
Page 98
98 Section 8: Program Branching and Controls Looping Looping is an application of branching which uses a t instruction to repeat a portion of the program. A loop can continue indefinitely, or may be conditional. A loop is frequently used to repeat a calculation with different variables. At the same time, a counter, which increments with each loop, may be included to keep track of loop iterations. This counter can then be checked with a conditional...
Page 99
Section 8: Program Branching and Controls 99 In this way, a program can accommodate two different modes of input, such as degrees and radians, and make the correct calculation for the mode chosen. You set a flag if a conversion needs to be made, for instance, and clear it if no conversion is needed. Suppose you had an equation requiring temperature input in degrees Kelvin, although sometimes your data might be in degrees Celsius. You could use a program with a flag to...
Page 100
100 Section 8: Program Branching and Controls Flag 9. An overflow condition (described on page 61) automatically sets flag 9. Flag 9 causes the display to blink or, if a program is running, waits until execution is complete and then starts blinking the display. Flag 9 may be cleared in three ways: Press | 9 (the common procedure for clearing flags). Press −. This will only clear flag 9 and stop the blinking—it will not clear the display. Turn the calculator off....