Possible bug in WP34s with big integers


I was working at generating toy RSA keys for algorithm exploration and created 2 32-bit primes (P and Q). I decremented each one in 2c64 mode and multiplied them together to get N = (P-1)(Q-1).

However, the number I get is missing the MSbit.

On VERS 1145:

With R77 = 0xF138552D (a prime)
and R78 = 0xAAC9B7A5 (a prime)

001 LBL A
002 WSIZE 64
003 2COMPL
004 BASE 16
005 RCL 77
006 DEC X
007 RCL 78
008 DEC X
009 [times]
010 RTN

The answer WP34s gives is: 0x20ED7AD3E4850430.

In BC:

A0ED7AD3E4850430 (This is correct. The MSbit should be set.)

I also repeated this in 1c64 mode with the same result. Any ideas? Have I overflowed something? I think this value should have been within range of [1-2]c64.

Best regards...


Oops! That's obviously phi(n) not n but still likely a bug. :-)


The answer WP34s gives is: 0x20ED7AD3E4850430.

....and leaving the overflow flag set. Since the MSB is the sign, the value would not be able to be represented in only 63 bits and if the MSB was able to be set, the value would erroneously go negative. If you run the program in the 34S and receive 20ED 7AD3 E485 0430 as a result, then get the leading hex digit to become an A by the following: 100000000000 ENTER 10000 * + 100000000000 ENTER 70000 * +, switching to decimal generates -6,850,684,407,670,045,648. Also, doing the problem in unsigned mode results in a decimal value of 11,596,059,666,039,505,968. The log(base 2) of this value is 63.33..., so since more than 63 bits would be needed to represent it, the signed 64-bit modes could not hold it. I think the 34S is okay.




Argh! You are so right! I had meant to set unsigned mode.

It works now that I have done that.

Thanks a bunch!!


I just tested it in unsigned mode and the result is as you expected.


This isn't a bug as folks have already identified: negative * negative gives positive. If the now not so recent change to bring multiplication sign handling into line with the 16c wasn't made, I think the answer would have been what you expected.

- Pauli

Possibly Related Threads...
Thread Author Replies Views Last Post
  OT--Found!!! An HP reference on 'The Big Bang Theory' Matt Agajanian 0 767 11-08-2013, 10:23 PM
Last Post: Matt Agajanian
  HP Prime: Long integers (continued) Helge Gabert 2 1,053 11-07-2013, 11:24 AM
Last Post: Helge Gabert
  HP Prime: Pass "Long" Integers to a Program Helge Gabert 6 1,763 11-03-2013, 01:12 PM
Last Post: Helge Gabert
  wp34s binomial bug Andrew Nikitin 4 1,222 09-22-2013, 05:20 PM
Last Post: Paul Dale
  OT--'The Big Bang Theory' and RPN/HP--Any connections? Matt Agajanian 19 3,706 09-05-2013, 08:27 AM
Last Post: Adrien Bertrand
  Expon bug in wp34s Andrew Nikitin 7 1,584 07-14-2013, 03:23 AM
Last Post: Marcus von Cube, Germany
  another wp34s bug Andrew Nikitin 8 1,710 06-26-2013, 01:01 AM
Last Post: Paul Dale
  weird statistics bug in wp34s Andrew Nikitin 5 1,580 06-20-2013, 01:54 PM
Last Post: Namir
  [WP34S] A funny bug in Pi (prod) Eduardo Duenez 3 970 01-28-2013, 03:41 AM
Last Post: Walter B
  Able to set HP 48G axis tick marks at integers? Randal B 1 745 01-24-2013, 12:40 AM
Last Post: Chris Dreher

Forum Jump: