The Museum of HP Calculators

HP Forum Archive 07

[ Return to Index | Top of Index ]

(HP48) " IFT " command problem . . .
Message #1 Posted by Tal on 24 Jan 2002, 5:49 a.m.

Hi, All!

I wonder what is the problem with this command:

IFT (k 18 == i 90 < AND,'i' 22 STO+)

Best regards, Tal

      
Re: (HP48) " IFT " command problem . . .
Message #2 Posted by Vieira, Luiz C. (Brazil) on 24 Jan 2002, 6:33 a.m.,
in response to message #1 by Tal

Hi;

it seems you mixed RPL with algebraics. IFTE can be used in an algebraic expression, but IFT cannot. I sugest this solution:

k 18 ==              @obtains a flag
i 90 <               @obtains the other flag
AND                  @returns final flag
<< 22 'i' STO+ >>    @program to be discarded (flag = 0) or executed
IFT                  @the command itself
Hope it helps.

Cheers.

            
Re: (Vieira) " IFT " command problem . . .
Message #3 Posted by Tal on 24 Jan 2002, 7:28 a.m.,
in response to message #2 by Vieira, Luiz C. (Brazil)

Hi, Vieira!

Thank you for your reply.

Do you think that this method:

k 16 == i 22 > j 32 < AND i 66 > j 46 == AND OR AND \<< 'i' 22 STO- \>> IFT

is faster then this one:

k 16 == i 22 > j 32 < AND i 66 > j 46 == AND OR AND THEN 'i' 22 STO- END

Best regards, Tal

                  
Re: (Vieira) " IFT " command problem . . .
Message #4 Posted by Vieira, Luiz C. (Brazil) on 24 Jan 2002, 8:02 a.m.,
in response to message #3 by Tal

Hi, Tal;

Let´s consider that when the program is running, the IFT structure will always place the object to be evaluated (in this case the program, that can be small or big) in the stack (normaly, Level 1). Then, after testing the flag (in Level 2), this object will be evaluated or not. The IF..THEN...(ELSE...)END structure will execute (evaluate) each command inside the THEN clause at a time, needing no extra time (some nano-seconds?) to load them all in the stack prior to their evaluation (execution).

To be honest, I cannot ´guess´ which is the fastest. The sequence to generate the flag - k 16 == i 22 > j 32 < AND i 66 > j 46 == AND OR AND - will be time consuming, too. I am not sure, but for this case it will be the same.

If you need to be sure about it, create a 1000-count loop (say, << 1 1000 START procedure NEXT >>) and test for both procedures. I would do that, you bet.

Sorry not helping much more.

Cheers.


[ Return to Index | Top of Index ]

Go back to the main exhibit hall