Post Reply 
(12C) Modulus
07-28-2016, 11:01 PM (This post was last modified: 07-28-2016 11:02 PM by bshoring.)
Post: #7
RE: (12C) Modulus
(07-25-2016 09:46 AM)Dieter Wrote:  
(07-25-2016 09:17 AM)I Wrote:  Here's another challenge: what about returning y mod x as well as y div x (i.e. the integer quotient of y and x). There are many applications where both values are required at the same time. That's why I once suggested a DIVMOD command for the 34s that returns these two values.

I just realized that the code in the previous post can be extended easily to return both values at the same time – it's just two more steps:

Code:
01 ENTER
02 ENTER
03 -
04 +
05 /
06 LastX
07 x<>y
08 INT
09 ENTER
10 R↓
11 x
12 -
13 GTO 00 or RTN

The same can be done with the Dodin/Jarett program by inserting ENTER R↓ between step 08 and 09.

The above version returns the remainder in X (and Z) and y div x in Y (and T).

3782 [ENTER] 72 [R/S]
=>  38   [X<>Y]   52

There even is a third useful result:

[LastX] => 3744
The largest number ≤ Y that is divisible by X.

Dieter

Nice program.

When I run 3782 [ENTER] 72 [R/S],
it leaves 38 in X only and 52 in Y, Z, & T.

Works for me.


Regards,
Bob
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(12C) Modulus - Eddie W. Shore - 07-15-2016, 02:37 AM
RE: (12C) Modulus - Dieter - 07-15-2016, 06:32 PM
RE: (12C) Modulus - bshoring - 07-18-2016, 10:12 PM
RE: (12C) Modulus - RobertM - 07-21-2016, 11:36 PM
RE: (12C) Modulus - Dieter - 07-25-2016, 09:17 AM
RE: (12C) Modulus - Dieter - 07-25-2016, 09:46 AM
RE: (12C) Modulus - bshoring - 07-28-2016 11:01 PM
RE: (12C) Modulus - Dieter - 07-29-2016, 05:39 PM



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