Commit c658f6d8 authored by Morten Welinder's avatar Morten Welinder

agm: minor code rearrangement.

Handle the a==b case early.  No need for iteration.
parent b2c7bdd6
2018-11-18 Morten Welinder <terra@gnome.org>
* src/mathfunc.c (gnm_agm): Short-circuit the a==b case early. We
only need it for +inf, but it's valid and meaningful for all values.
2018-11-17 Morten Welinder <terra@gnome.org>
* src/gui-util.c (gnm_create_popup_menu): Use a
......
......@@ -4990,14 +4990,16 @@ gnm_agm (gnm_float a, gnm_float b)
if (a < 0 || b < 0 || gnm_isnan (ab))
return gnm_nan;
if (a == gnm_pinf || b == gnm_pinf)
return gnm_pinf;
if (a == 0 || b == 0)
return 0;
if (a == b)
return a;
if (ab == 0 || ab == gnm_pinf) {
// Underflow or overflow
int ea, eb;
if (a == 0 || b == 0)
return 0;
// Underflow or overflow
(void)gnm_frexp (a, &ea);
(void)gnm_frexp (b, &eb);
scale = gnm_ldexp (1, -(ea + eb) / 2);
......
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