Commit bc07921d authored by Morten Welinder's avatar Morten Welinder

R.DBINOM: Avoid overflow and assert for extreme values.

parent 831176a5
2016-01-06 Morten Welinder <terra@gnome.org>
* src/mathfunc.c (ebd0): Fix problem with overflow. [#760230]
2016-01-04 Morten Welinder <terra@gnome.org>
* src/sheet-style.c (sheet_style_apply_range)
......
......@@ -10,6 +10,7 @@ Morten:
* Improve test suite.
* Fuzzed file fixes. [#760046] [#760085] [#760087] [#760089]
[#760043] [#760103] [#760102] [#760101] [#760105] [#760106]
* Fix R.DBINOM extreme-value case. [#760230]
--------------------------------------------------------------------------
Gnumeric 1.12.26
......
......@@ -240,8 +240,8 @@ static const float bd0_scale[128 + 1][4] = {
static void
ebd0(gnm_float x, gnm_float M, gnm_float *yh, gnm_float *yl)
{
gnm_float r, f, fg, M1;
int e;
gnm_float r, r1, r2, f, fg, M1;
int e, e1, e2;
int i, j;
const int Sb = 10;
const double S = 1u << Sb;
......@@ -257,8 +257,10 @@ ebd0(gnm_float x, gnm_float M, gnm_float *yh, gnm_float *yl)
g_printerr ("x=%.20g M=%.20g\n", x, M);
#endif
/* FIXME: handle overflow/underflow in division below */
r = gnm_frexp (M / x, &e);
r1 = gnm_frexp (M, &e1);
r2 = gnm_frexp (x, &e2);
r = gnm_frexp (r1 / r2, &e);
e += (e1 - e2);
i = gnm_floor ((r - 0.5) * (2 * N) + 0.5);
g_assert (i >= 0 && i <= N);
f = gnm_floor (S / (0.5 + i / (2.0 * N)) + 0.5);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment