Integer division on HP 33S


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.


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.





I use 'em!

(Or, rather, used them ...)


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.


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?




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.



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:
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:
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:

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


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!


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


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





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!


"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


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.


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.


-- Antonio


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


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


This applies to Rmdr too, of course!

-- Antonio



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


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.


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


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.



e.young wrote:

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


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



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 3,042 10-30-2013, 03:29 AM
Last Post: parisse
  HP Prime: Edit integer in RPN mode plivesey 15 4,090 10-18-2013, 04:34 PM
Last Post: kris223
  Prime Edit Integer kris223 8 2,100 09-24-2013, 06:43 PM
Last Post: kris223
  Why does PEMDAS do multiplication and division before addition and subtraction? Don Shepherd 12 2,728 07-31-2013, 10:59 AM
Last Post: robert rozee
  Understanding HP-16C integer division Jimi 18 4,183 10-16-2012, 09:13 PM
Last Post: Eddie W. Shore
  Truncating to Integer & Fraction--HP-35A/21A Matt Agajanian 11 2,493 03-31-2012, 10:36 PM
Last Post: Matt Agajanian
  WP34S x=? in integer mode Harald 8 1,890 03-13-2012, 07:00 PM
Last Post: Paul Dale
  Wp34s beta 2: possible serious bug in integer mode Cristian Arezzini 3 1,050 06-10-2011, 06:01 PM
Last Post: Cristian Arezzini
  wp34s Integer Word Size versus 16C Jake Schwartz 7 1,853 05-06-2011, 02:19 AM
Last Post: Walter B
  Corvallis Division - DIV.39 Joerg Woerner 3 1,268 09-13-2010, 04:15 PM
Last Post: Martin Pinckney

Forum Jump: