Post Reply 
integer division
02-01-2014, 06:06 PM (This post was last modified: 02-02-2014 09:18 AM by J-F Garnier.)
Post: #6
RE: integer division
First calculate R:
R=MOD(C*1E12,X)
then
Q=(C*1E12-5E11*X-R)/X+5E11

The trick is to shift the result Q by -5E11 to avoid the rounding in the division.
I leave the implementation on the HP42S as an exercice...

This reminds me the famous S&S math challenges some years ago - Hello Valentin, if you are still around!

J-F

Added: Unfortunatly, this formula still fails for some cases... Needs more tuning, finally will not be so simple.
Visit this user's website 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)