View Single Post
  #15   Report Post  
Posted to microsoft.public.excel.worksheet.functions,microsoft.public.excel
[email protected] mwelinder@gmail.com is offline
external usenet poster
 
Posts: 2
Default An oddity if not a bug

Harlan Grove wrote:

But let's compare apples to apples. In OpenOffice Calc,

=(COMBIN(9;3)-INT(COMBIN(9;3)))

returns 0, while the comparable formula in Gnumeric returns 0, but it
returns the same fractional result as in Excel when used as a term in
longer formulas. The comparable formula in Lotus 123 returns 0.


OO's minus is special in that almost-equal values are deemed to have
a zero difference. Similarly for equality (which isn't transitive as a
result). That means that getting zero above does not tell you
anything about COMBIN's accuracy.

Gnumeric returns an integer COMBIN result because it seemed like
a good idea when mucking with logs. Note the floor(0.5 + ...) in this
fragment:

if (k < 0 || k n)
return gnm_nan;
else if (n = 15)
return gnm_floor (0.5 + gnm_exp (gnm_lgamma (n + 1) - gnm_lgamma (k +
1) - gnm_lgamma (n - k + 1)));
else
return fact (n) / fact (k) / fact (n - k);

And fact will return an exact (and thus integer) value for n<=15 and
probably more.

Morten