Integer division on HP 33S



#24

Hi everybody,

I don't know if anyone has already posted such topic, but here it is.

The HP-33S has the integer division. The algorithm, while used by
keyboard or into a program, returns correct results (or at least I
expect them to be correct), but not in EQN:

Operation  INT÷  Rmdr   IDIV(EQN)  RMDR(EQN) INT÷(PRGM) RMDR(PRGM)   
9 / 7 1 2 1 2 1 2
9 /-7 -2 -5 -1 -5 -2 -5
-9 /-7 1 -2 1 -2 1 -2
-9 / 7 -2 5 -1 5 -2 5

The previous results for IDIV are not number theory results, but
pretty divisions between reals turned to integer form. Notice
besides that RMDR return the same results.

The curious thing is that I used the same key (INT÷) on the calculator for the three cases.

Any more news?

-- Antonio

Edited to add PRGM case.

Edited: 1 Aug 2006, 10:18 a.m.


#25

Wow! This looks similar to the negative HMS bug on the original 33s. Why the keypad entry, program and equation calls yield different results is a mystery.

It's too bad this wasn't discovered earlier so that Kinpo could have fixed it in later releases. I'm not effected by this bug as I don't use these functions but I wonder how many others are.

One work around is to take the absolute value of the Y and X registers before using the Integer and Remainder functions.

Regards,

John


#26

Ouch!

I use 'em!

(Or, rather, used them ...)


#27

Who will send an official remark to HP to force it fix this bug in later versions?

-- Antonio

Edited: 2 Aug 2006, 4:24 a.m.


#28

Hi Antonio. I see three possibilities for reporting this:

o Call HP and report the bug.

o Review the bug with HP at HHC 2006.

o Does anyone maintain a database for 33s bugs (ie. bugzilla, etc.)? If so, that's another option.

Did these functions exist in the 32s / 32sii or are they new in the 33s? What other functions still need to be fully tested?

Regards,

John


#29

This stupid integer crap was added with the 33s. There was a lengthy discussion of this business a couple years ago when the 33s first came out. Somewhererin the archives.

#30

Hello,

I can garentee you will get the message across (to Cyrille and his boss) if you bring this up at the Conference. For the Conference details see the two resources below.

Check out the 32nd “annual” Hewlett-Packard User Community,
HPUC, HP Handheld Conference, HHC, at:
http://holyjoe.net/hhc2006/
This year you will find a great deal of additional information
of interest to any serious HP handheld user. The website is updated
frequently. If you want the latest and fastest form of HPUC
information sign up (no charge) for the HHC List at:
http://lists.handheld.org/mailman/listinfo/hhc
You may post questions regarding the HHC and you may
provide your inputs as to what happens at the Conference. It
is your conference so make your views known by writing the
HHC Committee or posting on the above list.

Also check Eric Rechlin's web site at:

http://www.hpcalc.org/

While I didn't see a specific bug reporting section on the main page I thought that Eric accepted bug reports. I will check on this. Perhaps it is only for the high end machines.

X < > Y,

Richard J. Nelson

#31

Quote:
This looks similar to the negative HMS bug on the original 33s.

What was this bug? I just bought an 33s on ebay, s/n CNA 51501368. How can I check? Thanks in advance for some info!

#32

Antonio --

Another interesting find! To mix American slang with French, "You da beta-tester par excellence!"

Yes, indeed, this looks like a bug. The HP-33S manual states that IDIV is the Equation-mode name of the "INT/" function on the keyboard, but the should perform the same way. The answers for IDIV when the two operands are of opposite sign are plainly incorrect, because they are not consistent with the result from "Rmdr".

Discussion of MOD/RMD took place here a year or two ago. It is noteworthy that the RMD function on the HP-16C performs differently than the MOD function on the HP-41C*, HP-42S, and HP-28/48/49.

RMD is defined only for integer arguments. It always returns +/-2 for the four cases you provided, consistent with its built-in integer arithmetic. E.g., -7 goes into 9 only -1 times, with a remainder of 2. 9 ENTER -7 / in DEC (base-10 integer) mode yields -1 as the answer, with the carry bit set.

"Rmdr" on the HP-33S acts like MOD, which returns +/-5 when the operands are of opposite sign. It seems as though the rule requires that the MOD remainder and the divisor be of the same sign.

-- KS


#33

I was able to duplicate the 33s's results using Microsoft Excel 2003's INT and MOD functions which are described at:

http://office.microsoft.com/en-us/assistance/HP052091421033.aspx

and

http://office.microsoft.com/en-us/assistance/HP052091821033.aspx

Regards,

John

#34

Remember the HP-71? The HP-71 had a function for all seasons, with 4 of them related to this issue:

x DIV y = IP(x/y)

RMD(x,y) = x - y * IP(x/y)

MOD(x,y) = x - y * FLOOR(x/y)

RED(x,y) = x - y * n, where n is the nearest integer to x/y

Well behaved functions, all.

Ya pays yer money, and ya takes yer choice!

#35

Quote:
"Rmdr" on the HP-33S acts like MOD, which returns +/-5 when the operands are of opposite sign. It seems as though the rule requires that the MOD remainder and the divisor be of the same sign.

What is the official theory behind integer division? I thought that:

a/b  -> a = q x b + r

where q is the integer division result and r is the rest; I thought that:

0 <= r <= b

and thus r to be only positive, but the HP-33S returns r as if it was defined as:

0 <= |r| <= |b|

and so I'm probably wrong.

Can you clear me this point?

-- Antonio

P.S. I'd like to be a beta tester for HP calculators, in order to
assure a behaviour for which anyone is satisfied! I'm afraid the HP-33S has undergone a very fast and superficial design...

... or not?

-- Antonio


#36

Antonio --

I'd say that Rodger's post offers a concise reference. If you want more detail and rigorous definitions, an on-line site (such as Wolfram's Mathematica site) should provide it.

BTW, did you notice that I announced an update to my Achive Articel #556 regarding SOLVE/INTEG?

-- KS

Edited: 3 Aug 2006, 10:34 p.m.


#37

KS --

Forgive me for the long delay (I was in vacation).

Yes, I noticed your Article, and I printed it. It is very good and complete.

Thanks.

-- Antonio

#38

To anyone interested --

In this page, located in Wikipedia, there is a good background theory about integer division.

According to this theory, a division a / b can be expressed as

a = qd + r

where

0 <= r < |d|

or, briefly, r is **ALWAYS** positive.

So the HP-33S gives always the _wrong_ result when b is negative. The singularity of the IDIV command in EQN mode is purely accessory.

So, I feel to give this advice: use every HP-33S command but the INT÷ one. Or, be sure that the divisor is positive (and of course, don't use it into EQN mode).

Let's wait for a reviewed model. HP, are you listening?

-- Antonio


#39

This applies to Rmdr too, of course!

-- Antonio

#40

Antonio,

Just out of curiosity, what do you use integer division for?


#41

The last time I used integer division was in 2nd or 3rd grade, back in the early '70s. Then we learned what to do with the remainder and never looked back until now.

#42

Interger division is very handy in calendrical calculations, e.g.


#43

A P.S. to my last post. The 16C in interger mode with its remainder function (RMD) and the 42S with its modulo function (MOD) also do the same job.

tm

#44

e.young wrote:

Quote:
what do you use integer division for?

Well, I don't use it that much, but when I buy something, I want it to work good.

If HP cannot set a decent behaviour for these functions, why put them into the machine? They could have been better replaced by more useful functions (like matrix dealing or a complex environment more complete).

That's why I'm trying to understand if they have done a good job. At the moment, it seems they didn't.

-- Antonio


#45

I don't know what your the problem is but the function works well for me.

tm

#46

I understand what you mean. I never use integer division, so I don't know if it works on any of my 33s's


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP Prime polynomial long division bluesun08 13 859 10-30-2013, 03:29 AM
Last Post: parisse
  HP Prime: Edit integer in RPN mode plivesey 15 914 10-18-2013, 04:34 PM
Last Post: kris223
  Prime Edit Integer kris223 8 532 09-24-2013, 06:43 PM
Last Post: kris223
  Why does PEMDAS do multiplication and division before addition and subtraction? Don Shepherd 12 843 07-31-2013, 10:59 AM
Last Post: robert rozee
  Understanding HP-16C integer division Jimi 18 1,106 10-16-2012, 09:13 PM
Last Post: Eddie W. Shore
  Truncating to Integer & Fraction--HP-35A/21A Matt Agajanian 11 639 03-31-2012, 10:36 PM
Last Post: Matt Agajanian
  WP34S x=? in integer mode Harald 8 467 03-13-2012, 07:00 PM
Last Post: Paul Dale
  Wp34s beta 2: possible serious bug in integer mode Cristian Arezzini 3 242 06-10-2011, 06:01 PM
Last Post: Cristian Arezzini
  wp34s Integer Word Size versus 16C Jake Schwartz 7 455 05-06-2011, 02:19 AM
Last Post: Walter B
  Corvallis Division - DIV.39 Joerg Woerner 3 294 09-13-2010, 04:15 PM
Last Post: Martin Pinckney

Forum Jump: