Post Reply 
(12C) Long Division
07-14-2018, 05:08 PM (This post was last modified: 07-14-2018 05:10 PM by Dieter.)
Post: #4
RE: (12C) Long Division
(07-14-2018 08:05 AM)Carsen Wrote:  You have a very unorthodox method of getting the answer.

Actually Gamo's method is not unorthodox but the preferred approach as it (mostly) avoids roundoff errors.

You should never use FRAC when calculating the modulus as it may and will cause errors. Consider your example: the result is not 240 but 240,0000001. Then try 960 and 7, this returns a remainder of 0,999999700.

(07-14-2018 08:05 AM)Carsen Wrote:  I would add an extra swap command at the end of my program just so I could have the remainder in the Y register.

Agreed. Here is my attempt. Like your version (and unlike Gamo's) it does not require a double ENTER to separate the two arguments. The initial commands push Y to the higher stack levels and then drop it down again.

Code:
01 ENTER
02 ENTER
03 CLX
04 ×
05 +
06 ÷
07 LSTx
08 X<>Y
09 INTG
10 ENTER
11 R↓
12 ×
13 -
14 X<>Y

960 [ENTER] 360 [R/S] => 2 [X<>Y] 240

(07-14-2018 08:05 AM)Carsen Wrote:  But it is a great feeling to create a program in the 12C and not convert any registers so I didn't.

That's one of the biggest advantages of RPN. You can do many things directly on the stack, without any data registers.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(12C) Long Division - Gamo - 07-14-2018, 04:17 AM
RE: (12C) Long Division - Carsen - 07-14-2018, 08:05 AM
RE: (12C) Long Division - Dieter - 07-14-2018 05:08 PM
RE: (12C) Long Division - Carsen - 07-14-2018, 08:15 PM
RE: (12C) Long Division - Gamo - 07-14-2018, 09:44 AM
RE: (12C) Long Division - Gamo - 07-15-2018, 02:50 AM
RE: (12C) Long Division - Gamo - 07-02-2021, 12:26 AM



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