Binomial Coefficient
John W. Eaton
jwe at octave.org
Wed Jan 14 13:10:35 CST 2009
On 14-Jan-2009, Doug Stewart wrote:
| Pascal Bauer wrote:
| > Hi List,
| >
| > it seems to me, that the routine which calculate the binomial
| > coefficient has a problem (it gives wrong answers).
| >
| > octave:1> printf("%i\n",nchoosek(81, 27))
| > 2306279447501836648448
| >
| > But the correct value is
| >
| > 2306279447501851002720
| >
| > Cheers
| >
| > Pasci
| > ------------------------------------------------------------------------
| >
| > _______________________________________________
| > Bug-octave mailing list
| > Bug-octave at octave.org
| > https://www-old.cae.wisc.edu/mailman/listinfo/bug-octave
| >
| octave:4> nchoosek(81, 27)
| warning: nchoosek: possible loss of precision
| ans = 2.30627944750185e+21
|
| Did you see the warning????
That warning is a recent addition to the development sources. I don't
think it is in 3.0.3.
In any case, I don't see anything to fix here. The focus of Octave is
floating point math, not unlimited precision integer calculations.
jwe
More information about the Bug-octave
mailing list