INV DSZ in its natural habitat
|
10-15-2021, 01:56 PM
Post: #1
|
|||
|
|||
INV DSZ in its natural habitat
Yesterday there was some question as to whether or not the INV DSZ (decrement and skip if not zero) instruction present on some TIs was at all useful. I maintain that it's useful in any situation where you decrement a counter and break out of the middle of a loop, rather than at the end of the loop body.
I put together a little example by way of a cumulative binomial distribution program. First, a BASIC version for the 71B that makes the algorithm a little easier to read: Code: 0001 DESTROY ALL To use it, run the program, enter the number of trials N, the probability of success in a single trial P, and the number of successful trials X. The program will show the cumulative lower tail binomial probability, i.e. probability of the number of successes being between 0 and X. Note line 90, where the program decrements a counter, and breaks out of the middle of the loop (lines 80 to 110) when the counter reaches zero. Now, here are printouts of both an HP 97 version, and a TI-59 version. On the HP version, you have to do something like using an extra LBL and GTO to invert the DSZ test behavior. On the TI-59, you can simply use INV DSZ directly. To run either of these, store N in R01, P in R02, X in R03, and press A. https://i.imgur.com/rxENjWN.jpg Ignoring the fact that the TI program is about twice the size of the HP one it's clear that this is a case where INV DSZ can be used to save a couple of steps, and make the program flow easier to read. |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
INV DSZ in its natural habitat - Dave Britten - 10-15-2021 01:56 PM
RE: INV DSZ in its natural habitat - BruceH - 10-15-2021, 04:18 PM
RE: INV DSZ in its natural habitat - Dave Britten - 10-15-2021, 04:24 PM
RE: INV DSZ in its natural habitat - Ross Barnes - 10-16-2021, 12:12 AM
RE: INV DSZ in its natural habitat - xerxes - 10-18-2021, 06:38 PM
RE: INV DSZ in its natural habitat - Dave Britten - 10-19-2021, 06:54 PM
RE: INV DSZ in its natural habitat - xerxes - 10-19-2021, 09:03 PM
|
User(s) browsing this thread: 1 Guest(s)