Binomial Coefficient
David Bateman
dbateman at dbateman.org
Wed Jan 14 15:06:48 CST 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????
>
> Doug
>
>
Read the paper " What Every Computer Scientist Should Know about
Floating-Point Arithmetic <http://www.validlab.com/goldberg/paper.ps>"
(url http://www.validlab.com/goldberg/paper.ps ), about the consequences
of the choices in the IEEE754 standard and if you don't like them use a
CAS like Maxima instead of Octave.
D.
--
David Bateman dbateman at dbateman.org
35 rue Gambetta +33 1 46 04 02 18 (Home)
92100 Boulogne-Billancourt FRANCE +33 6 72 01 06 33 (Mob)
More information about the Bug-octave
mailing list