www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - BigInt problem

reply tsukikage <tsukikage dmail.com> writes:
Please see source in attachment.
The output is

  M2 M3 M5 M7 M13 M17 M19 M31 M61 M89 M107 M127 M521 M607 M1279 M2203 M2281
M3217 M4253 M4423
*** M9689***
  M9941 M11213 M19937
*** M21701***
  M23209

It missed 2 Mersenne Primes 9689 & 21701.
Is it my program bug or bigint broken?
It seems subtle.

Thank you!
Feb 12 2011
next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
tsukikage:

 Is it my program bug or bigint broken?
http://d.puremagic.com/issues/show_bug.cgi?id=5568 Bye, bearophile
Feb 12 2011
parent reply tsukikage <tsukikage dmail.com> writes:
For curiosity, would you explain/guess a possible reason for that?
Thanks!

bearophile wrote:
 tsukikage:
 
 Is it my program bug or bigint broken?
http://d.puremagic.com/issues/show_bug.cgi?id=5568 Bye, bearophile
Feb 13 2011
parent bearophile <bearophileHUGS lycos.com> writes:
tsukikage:

 For curiosity, would you explain/guess a possible reason for that?
I leave the answer to Don, I don't know the internals of D BigInts. Multi-precision integers are basic bricks used to build many other programs. How can you be sure they don't contain bugs that break your heavy numeric code? This is a big problem. Bye, bearophile
Feb 13 2011
prev sibling parent Don <nospam nospam.com> writes:
tsukikage wrote:
 Please see source in attachment.
 The output is
 
  M2 M3 M5 M7 M13 M17 M19 M31 M61 M89 M107 M127 M521 M607 M1279 M2203 
 M2281 M3217 M4253 M4423
 *** M9689***
  M9941 M11213 M19937
 *** M21701***
  M23209
 
 It missed 2 Mersenne Primes 9689 & 21701.
 Is it my program bug or bigint broken?
 It seems subtle.
 
 Thank you!
 
That's quite a terrible bug in Bigint. It's slipped through testing because of a fault in the win32 Phobos makefile (someone disabled asserts!). If Phobos is compiled in debug mode, your code causes an assert failure inside the bigint code. It's a straightforward problem with the fast recursive division implementation, failing to properly normalize intermediate quotients. Unfortunately the fix won't make the next release, which happens in a few hours.
Feb 18 2011