Possible bug in WP34s with big integers Neil Hamilton (Ottawa) Senior Member Posts: 255 Threads: 22 Joined: May 2011 06-22-2011, 12:30 PM 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: ```ibase=2^4 obase=2^4 p=F138552D q=AAC9B7A5 n=(p-1)*(q-1) n 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... Neil Hamilton (Ottawa) Senior Member Posts: 255 Threads: 22 Joined: May 2011 06-22-2011, 02:26 PM Oops! That's obviously phi(n) not n but still likely a bug. :-) Jake Schwartz Senior Member Posts: 349 Threads: 66 Joined: Apr 2007 06-22-2011, 04:08 PM Quote: 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. Jake Jake Marcus von Cube, Germany Posting Freak Posts: 3,283 Threads: 104 Joined: Jul 2005 06-22-2011, 04:27 PM I just tested it in unsigned mode and the result is as you expected. Neil Hamilton (Ottawa) Senior Member Posts: 255 Threads: 22 Joined: May 2011 06-22-2011, 04:28 PM Argh! You are so right! I had meant to set unsigned mode. It works now that I have done that. Thanks a bunch!! Paul Dale Posting Freak Posts: 3,229 Threads: 42 Joined: Jul 2006 06-22-2011, 04:46 PM 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 « Next Oldest | Next Newest »

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

Forum Jump: