With dmd 2.055 under Linux x86-64, (BigInt(10)^^p)^^2 doesn't return the correct result starting from p == 32: import std.stdio, std.bigint; void main() { for( int p = 0 ; p < 40 ; p++ ) { BigInt n = BigInt(10)^^p; BigInt a = n*n; BigInt b = n^^2; if( a != b ) { writefln( "%s %s %s %s", p, n, a, b ); } } } It also fails with BigInt(2)^^p (from p==32 too) and BigInt(20)^^p (from p==16). Values like (BigInt(2)^^32+1)^^2 are computed correctly.
Ouch. There's a shift by 32 missing. Looks like a fencepost error. Raising to critical.
https://github.com/D-Programming-Language/phobos/commit/1d3a9d22766a3dbcb0063ef907f3e0dd32382a6d
(In reply to comment #2) I've just built and tried latest git (dmd2+druntime+libphobos2) and both the small test above and my original program that triggered the bug now work correctly. Thanks!