Possible bug in WP34s with big integers - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: Possible bug in WP34s with big integers (/thread-186720.html) Possible bug in WP34s with big integers - Neil Hamilton (Ottawa) - 06-22-2011 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... Re: Possible bug in WP34s with big integers - Neil Hamilton (Ottawa) - 06-22-2011 Oops! That's obviously phi(n) not n but still likely a bug. :-) Re: Possible bug in WP34s with big integers - Jake Schwartz - 06-22-2011 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 Re: Possible bug in WP34s with big integers - Marcus von Cube, Germany - 06-22-2011 I just tested it in unsigned mode and the result is as you expected. Re: Possible bug in WP34s with big integers - Neil Hamilton (Ottawa) - 06-22-2011 Argh! You are so right! I had meant to set unsigned mode. It works now that I have done that. Thanks a bunch!! Re: Possible bug in WP34s with big integers - Paul Dale - 06-22-2011 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