Long Division program
|
08-25-2017, 06:47 AM
(This post was last modified: 08-25-2017 07:35 AM by Gamo.)
Post: #1
|
|||
|
|||
Long Division program
Got this nice Long Division program from HP Key Notes newsletter (1977 issue)
Anyone have the idea on how to adapt this program to work on HP 12C will be nice. 001 *LBL A 002 / 003 LSTX 004 X<>Y 005 ENT^ (ENTER) 006 FRC (FRAC) 007 X<>Y 008 INT (INTG) 009 R down 010 x 011 EEX 012 4 013 / 014 R up (no key) 015 + 016 DSP4 (FIX4) 017 RTN (no key) 018 R/S To use the routine press ENTER key in divisor and press A Example: 4359 ENTER, 57 A ------ 76.0027 Quotient = 76, Remainder = 27 Gamo |
|||
08-26-2017, 05:54 PM
(This post was last modified: 08-26-2017 06:03 PM by Dieter.)
Post: #2
|
|||
|
|||
RE: Long Division program
(08-25-2017 06:47 AM)Gamo Wrote: Anyone have the idea on how to adapt this program to work on HP 12C will be nice. ?!? – where's the problem, this HP67 program (I suppose) can be used almost 1:1 on the 12C. OK, the 12C has no labels, so remove the first line. And there is no roll up command, but that's the same as 3x roll down. Since there is no subroutine call the final RTN here works as a R/S, so simply ignore it. So if you want to you can directly use this program on the 12C, just with these minor modifications. Or consider this alternate solution: Code: 01 ENTER Hint: the first five lines fill T, Z and Y with the dividend while X holds the divisor. More important: this procedure calculates the remainder without the FRAC function which is the preferred method since it does not cause roundoff errors. 4359 ENTER 57 [R/S] => 27 [x<>y] 76 Add a final [x<>y] if you want to have it the other way round. Or add... Code: 14 EEX ....and the result is displayed as 76,0027. Dieter |
|||
08-26-2017, 06:17 PM
Post: #3
|
|||
|
|||
RE: Long Division program
(08-26-2017 05:54 PM)Dieter Wrote: Or consider this alternate solution: Same number of steps, but you always manage to cut a few off :-) Code:
Gerson. |
|||
08-26-2017, 06:30 PM
(This post was last modified: 08-27-2017 04:55 PM by Dieter.)
Post: #4
|
|||
|
|||
RE: Long Division program
(08-26-2017 06:17 PM)Gerson W. Barbosa Wrote: Same number of steps, but you always manage to cut a few off :-) Hmmm... that's another procedure for filling the stack in the desired way. But it also takes five steps. Edit: one step can be saved. Replace the first five steps with these four: Code: 01 ENTER If you want to minimize the step count it looks like you have to use a register: Code: 01 x<>y On the Woodstocks, Spices and similar devices a short and elegant method for storing X and Y simultaneously is CLΣ Σ+. But as far as I can see a CLΣ on the 12C seems to clear the whole stack. Yuk! Finally, as it has not been mentioned yet: if quotient and remainder are returned as qqqq,rrrr the divisor must not exceed 10 000. Edit: Since the roundoff error of the FRAC method should not show up if the result is returned as qqqq,rrrr (this rounds away the last four digits of the calculated remainder) one could also do it this way: Code: 01 ENTER That's three steps less than my original version. Or five steps less if there was a R↑ function to replace the three R↓. ;-) Dieter |
|||
08-27-2017, 11:51 AM
Post: #5
|
|||
|
|||
RE: Long Division program
Thank You for difference variation steps on how to solve this Long Division program. Very helpful to learn from your guys to see many difference ways to adapt these program from other HP calculator ( my example of Long Division program was from HP-41C ) because of the lack of many advance keys funtions of the HP 12C this make it to think harder for other way to program it.
Gamo |
|||
08-27-2017, 12:17 PM
(This post was last modified: 08-27-2017 12:43 PM by Dieter.)
Post: #6
|
|||
|
|||
RE: Long Division program
(08-27-2017 11:51 AM)Gamo Wrote: Very helpful to learn from your guys to see many difference ways to adapt these program from other HP calculator ( my example of Long Division program was from HP-41C ) No, your example definitely was a program for the HP67/97. Only these calculators have a DSP command for setting the number of displayed digits independent from the display mode (FIX/SCI/ENG) and on the '41 "EEX 4" is a single line (1E4). The way the commands are written also resembles the output of an HP97 printer ("ENT↑", labels with asterisk, etc.). If all this still doesn't convice you: in 1977 there was no 41C yet – it was introduced in 1979. ;-) BTW, in what 1977 Keynotes issue did you find this program? Edit: I finally found it on page 6 of V3N2 – but that is May 1979, not 1977 ! And still two months before the 41C appeared. Dieter |
|||
08-28-2017, 05:10 AM
Post: #7
|
|||
|
|||
RE: Long Division program
Was searching on newsletter and though that it was
41C You're right!! Gamo |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 4 Guest(s)