integer division
01-30-2014, 03:30 PM
Post: #1
 Werner Senior Member Posts: 887 Joined: Dec 2013
integer division
As part of a long division, I need to do the following on the 42S (but it applies to all HP calculators that do not have a DIV command):
Given C and X, C<X
determine Q and R so that

C*10^12 = Q*X+R

C,Q,R,X positive and less than 10^12

Sounds easy? It isn't, or I am missing something.
R is easy: MOD(C*10^12,X), absolutely correct.
Now for Q..

Try:

C=2 and X=3 (Q=666 666 666 666, R=2)
C=2e11+3, X=4e11 (Q=500 000 000 007, R=2e11)

Can you get the correct Q? For the second example, I still can't ;-)
(Well, that is not strictly correct: of course I can, but not quickly and elegantly :-)

Werner

41CVâ€ ,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
 « Next Oldest | Next Newest »

 Messages In This Thread integer division - Werner - 01-30-2014 03:30 PM RE: integer division - Thomas Klemm - 01-31-2014, 04:44 AM RE: integer division - Werner - 01-31-2014, 01:46 PM RE: integer division - Thomas Klemm - 01-31-2014, 03:50 PM RE: integer division - Werner - 01-31-2014, 06:33 PM RE: integer division - J-F Garnier - 02-01-2014, 06:06 PM RE: integer division - Werner - 02-02-2014, 06:08 PM

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