Post Reply 
integer division
02-02-2014, 06:08 PM
Post: #7
RE: integer division
No, you have to use INT(C0/(1e11*X) instead of 5e11.

Or you can calculate the two halves of the quotient separately, as follows:
Let every position denote 6 digits.
Then we have to split Cc00 into quotient Qq and remainder Rr:

Cc00 = Qq*Xx + Rr

Cc,Rr < Xx
or

Cc00 = Q0*Xx + q*Xx + Rr
Cc00 = Q*Xx0 + q*Xx + Rr

Here, q*Xx + Rr = MOD(Cc00,Xx0)

So,

Rr = MOD(Cc00,Xx)
Q = INT(Cc00/Xx0)
q = INT(MOD(Cc00,Xx0)/Xx)

Qq = Q0 + q

Code:
*LBL "DIV"
 RCL ST X
 1 e6
 *
 STO/ ST T
 X<>Y
 RDN
 MOD
 RUP
 /
 INT
 X<>Y
 INT
 1 e6
 *
 +
 END

Thomas did the same but used 1e11, splitting off only the first digit of Q

41CV†,42S,48GX,49G,DM42,DM41X,17BII,15CE,DM15L,12C,16CE
Find all posts by this user
Quote this message in a reply
Post Reply 


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)