BigInt Bug or just me?

2012-04-21 Thread Tyro[17]
Why does the following implementation of the binomial coefficient yield two different answers? import std.stdio, std.bigint; void main() { // Correct result when using long writeln((40 20) = , binomial(40L, 20L)); // 2 times the expected result when using BigInt writeln((40

Re: BigInt Bug or just me?

2012-04-21 Thread Jordi Sayol
Al 21/04/12 16:07, En/na Tyro[17] ha escrit: Why does the following implementation of the binomial coefficient yield two different answers? Only happens when compiling to 32-bit. 32-bit: (40 20) = 137846528820 (40 20) = 68923264410 64-bit: (40 20) = 137846528820 (40 20) = 137846528820

Re: BigInt Bug or just me?

2012-04-21 Thread Tyro[17]
On Saturday, 21 April 2012 at 14:30:49 UTC, Jordi Sayol wrote: Al 21/04/12 16:07, En/na Tyro[17] ha escrit: Why does the following implementation of the binomial coefficient yield two different answers? Only happens when compiling to 32-bit. 32-bit: (40 20) = 137846528820 (40 20) =

Re: BigInt Bug or just me?

2012-04-21 Thread Jordi Sayol
Al 21/04/12 16:42, En/na Tyro[17] ha escrit: Actually, in that case it only happens when compiling to 64-bit. Note: comb1(BigInt(40), BigInt(20))/2; The the BigInt version is being divided by two (on MAC OS X) in order to yield the correct result. You are right, sorry. My test was done