The following warnings occurred:
Warning [2] Undefined array key 229076 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 229087 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 229091 - Line: 275 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 275 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $thread - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $fid - Line: 295 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 295 errorHandler->error_callback
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined array key 229091 - Line: 331 - File: inc/plugins/threaded_mode.php PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php 331 errorHandler->error_callback
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 332 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 304 ThreadedMode::buildtree
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $theme - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Trying to access array offset on value of type null - Line: 3 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 3 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Undefined variable $lang - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks
Warning [2] Attempt to read property "messages_in_thread" on null - Line: 5 - File: inc/plugins/threaded_mode.php(305) : eval()'d code PHP 8.1.2-1ubuntu2.14 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/plugins/threaded_mode.php(305) : eval()'d code 5 errorHandler->error_callback
/inc/plugins/threaded_mode.php 305 eval
/inc/plugins/threaded_mode.php 23 ThreadedMode::showthread_threaded
/inc/class_plugins.php 142 threaded_mode_showthread_threaded
/showthread.php 918 pluginSystem->run_hooks





An old trick rediscovered: combining conditional tests



#2

Namir's post re. "question to TI58/59 programmers" reminded me of the olden days when the average calculator nerd had a comprehensive programmer's toolbox at hand, containing numerous clever ways to overcome the restrictions of the devices that were available at that time.

One of these tricks is the combination of conditional tests, one followed by another. Such a combination allows the construction of logical operations that are usually not available on programmable calculators, making programs shorter, faster and more elegant.

For instance, two consecutive tests A and B set up a logical disjunction, i.e. the combination behaves like an OR operator, leading to a test (NOT A) OR B. Or, the other way round, if you want to test if condition A or condition B is true, simply use the test for (NOT A) directly followed by B.

Example 1:

The sequence...

FC? 01
FS? 02
...tests if Flag 01 or (!) Flag 02 is set.

In a similar way, this helped back then to build those tests commands that were not available on contemporary hardware. Even the HP-41 did not feature a X>=Y? test, but this could be accomplished easily: According to the mentioned rule, a test like "X=Y? OR X>Y?" is equivalent to the sequence...

X!=Y?
X>Y?
Or, if you prefer,
X<=Y?
X=Y?
Such a combination of two tests can also be used to invert a test command. Simply make sure the second command always tests false. According to the stated rule, this is equivalent to (NOT A) OR FALSE, which in turn is logically the same as NOT A.

On the HP-41, flag 54 (only set during a PSE command) may be used for the always-negative test. For instance like this:

Example 2:

The already mentioned X>=Y? test missing on most classic HPs is equivalent to NOT(X<Y?), so it can be substituted by...

X<Y?
FS? 54
Example 3:

A DSE or DSZ that skips if the respective register is not zero. In other words, something like INV DSZ on TI machines. ;-)
...
DSE 03
FS? 54
GTO 02 // exit loop if R03 has become zero
... // otherwise continue
So combining conditional tests is a handy feature that makes user programs faster, shorter and more elegant.

But two consecutive tests is not where this idea ends. What about three commands - this will work just as well. Finally, can you figure out what this combination of four consecutive HP-41 flag tests will do?

FC? 01
FS? 02
FS? 54
FS? 03
I remember an old issue of some HP-related magazine where this subject was discussed in detail with regard to the HP-67/97. If you have access to this article, please do not cheat. ;-)

Dieter


#3

Hi.

I used this sequence once in a program back in the 80's just to provide a logical flip-flop, i.e., every time this sequence runs, the state of flag xx commutes. I am not sure if this is common knowledge, but here it goes:

FC?C xx
SF xx
Flag xx will act as a flip-flop each time these lines are executed.

Hope it is of any use.

Cheers.

Luiz (Brazil)

Edited: 12 Aug 2012, 3:17 p.m.


#4

Ah, yes, I used this technique more than 30 years ago for my first program implementing Simspon's rule. This way the function values were multiplied with 4, 2, 4, 2, 4, 2... :-)

The second version then used k := 6-k instead to provide the two alternating factors. And the final versions stored the odd and even function values separately so that a better estimate with twice the number of nodes needed to evaluate only those that had not been calculated before. Well, later I heard about the Romberg method... :-)

Dieter


Possibly Related Threads…
Thread Author Replies Views Last Post
  For my next trick... Dave Britten 3 1,500 07-25-2012, 07:11 PM
Last Post: Howard Owen
  HP-15C LE torture tests ckelley2 11 3,244 07-25-2012, 09:36 AM
Last Post: Gerson W. Barbosa
  HP48SX seems fully functional won't run SELF TESTS? Bruce Larrabee 5 1,942 07-16-2012, 11:04 PM
Last Post: Luiz C. Vieira (Brazil)
  HP 9100 display trick Juergen Keller 4 1,583 05-01-2012, 03:15 AM
Last Post: Bill Wiese
  15C LE self tests / how? db (martinez, ca.) 1 901 04-22-2012, 12:55 AM
Last Post: Ethan Conner
  Calculators on Standard Tests Norman Dziedzic 18 4,253 02-14-2012, 10:26 PM
Last Post: bill platt
  OT: AA Lithium Battery Tests Bill (Smithville, NJ) 5 1,818 12-08-2011, 10:01 AM
Last Post: Jim Yohe
  Another couple of practical speed tests for the 15c Jose Gonzalez Divasson 16 3,777 10-14-2011, 11:39 PM
Last Post: Reth
  The *REAL* Self Tests For the 15C LE Mike Morrow 15 3,971 09-12-2011, 02:14 PM
Last Post: Mike Morrow
  What is the trick to... Geoff Quickfall 2 1,145 06-22-2011, 12:18 PM
Last Post: Geoff Quickfall

Forum Jump: