The Museum of HP Calculators

HP Forum Archive 16

 Integer division on HP 33SMessage #1 Posted by Antonio Maschio (Italy) on 1 Aug 2006, 3:21 a.m. 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.

 Re: Integer division on HP 33SMessage #2 Posted by John Smitherman on 1 Aug 2006, 1:06 p.m.,in response to message #1 by Antonio Maschio (Italy) 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

 Re: Integer division on HP 33SMessage #3 Posted by Paul Brogger on 1 Aug 2006, 4:56 p.m.,in response to message #2 by John Smitherman Ouch! I use 'em! (Or, rather, used them ...)

 Re: Integer division on HP 33SMessage #4 Posted by Antonio Maschio (Italy) on 2 Aug 2006, 2:12 a.m.,in response to message #3 by Paul Brogger 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.

 Re: Integer division on HP 33SMessage #5 Posted by John Smitherman on 2 Aug 2006, 12:32 p.m.,in response to message #4 by Antonio Maschio (Italy) 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

 Re: Integer division on HP 33SMessage #6 Posted by bill platt on 2 Aug 2006, 1:34 p.m.,in response to message #5 by John Smitherman 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.

 Re: Integer division on HP 33SMessage #7 Posted by Richard J. Nelson on 16 Aug 2006, 8:11 p.m.,in response to message #5 by John Smitherman 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

 Re: Integer division on HP 33SMessage #8 Posted by Walter B on 2 Aug 2006, 4:03 p.m.,in response to message #2 by John Smitherman 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!

 Re: Integer division on HP 33SMessage #9 Posted by Karl Schneider on 3 Aug 2006, 12:11 a.m.,in response to message #1 by Antonio Maschio (Italy) 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

 Re: Integer division on HP 33SMessage #10 Posted by John Smitherman on 3 Aug 2006, 1:08 a.m.,in response to message #9 by Karl Schneider 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

 Re: Integer division on HP 33SMessage #11 Posted by Rodger Rosenbaum on 3 Aug 2006, 2:39 a.m.,in response to message #9 by Karl Schneider 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!

 Re: Integer division on HP 33SMessage #12 Posted by Antonio Maschio (Italy) on 3 Aug 2006, 2:39 a.m.,in response to message #9 by Karl Schneider 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

 Re: Integer division on HP 33SMessage #13 Posted by Karl Schneider on 3 Aug 2006, 11:03 a.m.,in response to message #12 by Antonio Maschio (Italy) 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.

 Re: Integer division on HP 33SMessage #14 Posted by Antonio Maschio (Italy) on 17 Aug 2006, 10:30 a.m.,in response to message #13 by Karl Schneider 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

 Re: Integer division on HP 33SMessage #15 Posted by Antonio Maschio (Italy) on 17 Aug 2006, 10:52 a.m.,in response to message #1 by Antonio Maschio (Italy) 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

 Re: Integer division on HP 33SMessage #16 Posted by Antonio Maschio (Italy) on 17 Aug 2006, 10:54 a.m.,in response to message #15 by Antonio Maschio (Italy) This applies to Rmdr too, of course! -- Antonio

 Re: Integer division on HP 33SMessage #17 Posted by e.young on 17 Aug 2006, 2:55 p.m.,in response to message #15 by Antonio Maschio (Italy) Antonio, Just out of curiosity, what do you use integer division for?

 Re: Integer division on HP 33SMessage #18 Posted by bill platt on 17 Aug 2006, 5:23 p.m.,in response to message #17 by e.young 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.

 Re: Integer division on HP 33SMessage #19 Posted by Trent Moseley on 20 Aug 2006, 5:23 p.m.,in response to message #17 by e.young Interger division is very handy in calendrical calculations, e.g.

 Re: Integer division on HP 33SMessage #20 Posted by Trent Moseley on 20 Aug 2006, 11:29 p.m.,in response to message #19 by Trent Moseley 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

 Re: Integer division on HP 33SMessage #21 Posted by Antonio Maschio (Italy) on 21 Aug 2006, 6:03 a.m.,in response to message #17 by e.young 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

 Re: Integer division on HP 33SMessage #22 Posted by Trent Moseley on 21 Aug 2006, 2:07 p.m.,in response to message #21 by Antonio Maschio (Italy) I don't know what your the problem is but the function works well for me. tm

 Re: Integer division on HP 33SMessage #23 Posted by e,young on 22 Aug 2006, 11:47 a.m.,in response to message #21 by Antonio Maschio (Italy) I understand what you mean. I never use integer division, so I don't know if it works on any of my 33s's

Go back to the main exhibit hall