New guy and programming problem
08-28-2017, 02:20 PM
Post: #22
 Logan Member Posts: 139 Joined: Jul 2016
RE: New guy and programming problem
So for completeness' sake, I'll add the response I left to you when you asked this question on my 42s programming video.

Sure, so what's happening is that if you enter a new value for R1 or R2 the stack is lifting and the old value is now in the Y portion of the stack, so ultimately your program is calculating the old R2 + 1/(new R2) and then 1/x.

A couple of solutions: the most straightforward is probably to store the intermediate value, so after the first 1/X, STO 00 and then after the second 1/X, RCL 00.

Or, perhaps a better practice is to create the variables first, then perform the operations:
Code:
LABEL "PAR2" INPUT R1 INPUT R2 1/X RCL R1 1/X + 1/X END

Lastly, if you wanted to be really streamlined, you could do away with INPUT altogether and just enter your values into the stack before executing the program
Code:
LABEL "PAR2" 1/X X <> Y 1/X + 1/X END
(Run by entering R1 ENTER R2 XEQ PAR2)
 « Next Oldest | Next Newest »

 Messages In This Thread New guy and programming problem - Skirmitch - 08-27-2017, 06:18 AM RE: New guy and programming problem - Dieter - 08-27-2017, 03:15 PM RE: New guy and programming problem - Gerson W. Barbosa - 08-27-2017, 05:12 PM RE: New guy and programming problem - Dieter - 08-27-2017, 05:43 PM RE: New guy and programming problem - Paul Dale - 08-27-2017, 11:12 PM RE: New guy and programming problem - Dieter - 08-28-2017, 06:13 PM RE: New guy and programming problem - Paul Dale - 08-29-2017, 04:22 AM RE: New guy and programming problem - Garth Wilson - 08-27-2017, 09:14 PM RE: New guy and programming problem - Vtile - 09-01-2018, 07:28 PM RE: New guy and programming problem - John Keith - 08-27-2017, 05:52 PM RE: New guy and programming problem - Dieter - 08-27-2017, 06:28 PM RE: New guy and programming problem - Gerson W. Barbosa - 08-27-2017, 06:03 PM RE: New guy and programming problem - Dieter - 08-27-2017, 06:11 PM RE: New guy and programming problem - Gerson W. Barbosa - 08-27-2017, 06:23 PM RE: New guy and programming problem - pier4r - 08-27-2017, 07:52 PM RE: New guy and programming problem - Jlouis - 08-28-2017, 10:55 AM RE: New guy and programming problem - Skirmitch - 08-27-2017, 06:04 PM RE: New guy and programming problem - Skirmitch - 08-28-2017, 01:44 AM RE: New guy and programming problem - Paul Dale - 08-28-2017, 01:58 AM RE: New guy and programming problem - Skirmitch - 08-28-2017, 02:25 AM RE: New guy and programming problem - Paul Dale - 08-28-2017, 05:31 AM RE: New guy and programming problem - Skirmitch - 08-28-2017, 07:14 AM RE: New guy and programming problem - ndzied1 - 08-28-2017, 03:43 AM RE: New guy and programming problem - Paul Dale - 08-28-2017, 07:28 AM RE: New guy and programming problem - Logan - 08-28-2017 02:20 PM RE: New guy and programming problem - Skirmitch - 08-28-2017, 06:11 PM RE: New guy and programming problem - Logan - 08-28-2017, 06:13 PM RE: New guy and programming problem - Thomas Klemm - 09-01-2018, 12:23 PM RE: New guy and programming problem - Albert Chan - 09-01-2018, 02:16 PM RE: New guy and programming problem - Albert Chan - 09-02-2018, 06:14 PM RE: New guy and programming problem - Albert Chan - 09-02-2018, 09:21 PM RE: New guy and programming problem - sasa - 09-01-2018, 03:18 PM RE: New guy and programming problem - Albert Chan - 09-01-2018, 05:20 PM RE: New guy and programming problem - sasa - 09-01-2018, 05:33 PM RE: New guy and programming problem - Thomas Klemm - 09-01-2018, 04:28 PM RE: New guy and programming problem - Thomas Klemm - 09-02-2018, 07:33 PM RE: New guy and programming problem - Thomas Klemm - 09-02-2018, 09:33 PM RE: New guy and programming problem - Vtile - 09-02-2018, 09:40 PM RE: New guy and programming problem - Albert Chan - 09-03-2018, 10:32 PM

User(s) browsing this thread: 1 Guest(s)