Commit 3df6e854 authored by Morten Welinder's avatar Morten Welinder Committed by Morten Welinder

Check for fmodl. Supply fmodgnum.

2002-10-11  Morten Welinder  <terra@diku.dk>

	* configure.in (have_ld): Check for fmodl.
	* src/numbers.h: Supply fmodgnum.

2002-10-11  Morten Welinder  <terra@diku.dk>

	* functions.c (gnumeric_mod): Handle non-integer args.
parent 7d0025d2
2002-10-11 Morten Welinder <terra@diku.dk>
* configure.in (have_ld): Check for fmodl.
* src/numbers.h: Supply fmodgnum.
* src/gutils.c (g_strsplit_to_list): Delete.
2002-10-11 Jon K Hellan <hellan@acm.org>
......
......@@ -44,6 +44,7 @@ Morten:
* Start handling invalid (== non-utf8) file names.
* Fix minor leak in excel loader.
* Improve precision of GEOMEAN and PRODUCT.
* Fix MOD for non-integer (or just huge) args.
dorami@bu.iij4u.or.jp:
* Add InputMethod support for better international key support
......
2002-10-11 Morten Welinder <terra@diku.dk>
* configure.in (have_ld): Check for fmodl.
* src/numbers.h: Supply fmodgnum.
* src/gutils.c (g_strsplit_to_list): Delete.
2002-10-11 Jon K Hellan <hellan@acm.org>
......
2002-10-11 Morten Welinder <terra@diku.dk>
* configure.in (have_ld): Check for fmodl.
* src/numbers.h: Supply fmodgnum.
* src/gutils.c (g_strsplit_to_list): Delete.
2002-10-11 Jon K Hellan <hellan@acm.org>
......
......@@ -368,7 +368,7 @@ AC_ARG_WITH(long_double,
need_sunmath=no
for ldfunc in fabsl sqrtl expl expm1l logl log10l log1pl ceill floorl powl hypotl \
sinl cosl tanl asinl acosl atanl atan2l \
sinl cosl tanl asinl acosl atanl atan2l fmodl \
sinhl coshl tanhl asinhl acoshl atanhl \
isnanl finitel; do
AC_CHECK_FUNC($ldfunc,
......
2002-10-11 Morten Welinder <terra@diku.dk>
* functions.c (gnumeric_mod): Handle non-integer args.
2002-09-30 Jody Goldberg <jody@gnome.org>
* Release 1.1.9
......
......@@ -1192,33 +1192,36 @@ static const char *help_mod = {
"@SEEALSO=INT,FLOOR,CEIL")
};
/*
* MOD(-1,-3) = -1
* MOD(2,-3) = -2
* MOD(10.6,2) = 0.6
* MOD(-10.6,2) = 1.4
* MOD(10.6,-2) = -0.6
* MOD(-10.6,-2) = -1.4
*/
static Value *
gnumeric_mod (FunctionEvalInfo *ei, Value **argv)
{
int a, b;
gnum_float a, b, babs, r;
a = value_get_as_int (argv[0]);
b = value_get_as_int (argv[1]);
a = value_get_as_float (argv[0]);
b = value_get_as_float (argv[1]);
if (b == 0)
return value_new_error (ei->pos, gnumeric_err_DIV0);
else if (b > 0) {
if (a >= 0)
return value_new_int (a % b);
else {
int c = (-a) % b;
return value_new_int (c ? b - c : 0);
}
} else {
b = -b;
a = -a;
if (a >= 0)
return value_new_int (-(a % b));
else {
int c = (-a) % b;
return value_new_int (c ? c - b : 0);
}
babs = gnumabs (b);
r = fmodgnum (gnumabs (a), babs);
if (r > 0) {
if ((a < 0) != (b < 0))
r = babs - r;
if (b < 0)
r = -r;
}
return value_new_float (r);
}
/***************************************************************************/
......
......@@ -75,32 +75,33 @@ gnum_float erfcgnum (gnum_float x);
gnum_float yngnum (int n, gnum_float x);
#endif
#define sqrtgnum sqrtl
#define gnumabs fabsl
#define floorgnum floorl
#define acosgnum acosl
#define acoshgnum acoshl
#define asingnum asinl
#define asinhgnum asinhl
#define atan2gnum atan2l
#define atangnum atanl
#define atanhgnum atanhl
#define ceilgnum ceill
#define powgnum powl
#define hypotgnum hypotl
#define cosgnum cosl
#define coshgnum coshl
#define expgnum expl
#define expm1gnum expm1l
#define loggnum logl
#define finitegnum finitel
#define floorgnum floorl
#define fmodgnum fmodl
#define gnumabs fabsl
#define hypotgnum hypotl
#define isnangnum isnanl
#define log10gnum log10l
#define log1pgnum log1pl
#define loggnum logl
#define powgnum powl
#define singnum sinl
#define cosgnum cosl
#define tangnum tanl
#define asingnum asinl
#define acosgnum acosl
#define atangnum atanl
#define atan2gnum atan2l
#define isnangnum isnanl
#define finitegnum finitel
#define sinhgnum sinhl
#define coshgnum coshl
#define sqrtgnum sqrtl
#define tangnum tanl
#define tanhgnum tanhl
#define asinhgnum asinhl
#define acoshgnum acoshl
#define atanhgnum atanhl
#define GNUM_FORMAT_e "Le"
#define GNUM_FORMAT_E "LE"
......@@ -118,38 +119,40 @@ gnum_float yngnum (int n, gnum_float x);
#else /* !WITH_LONG_DOUBLE */
typedef double gnum_float;
#define strtognum strtod
#define modfgnum modf
#define gnumabs fabs
#define ldexpgnum ldexp
#define frexpgnum frexp
#define sqrtgnum sqrt
#define floorgnum floor
#define acosgnum acos
#define acoshgnum acosh
#define asingnum asin
#define asinhgnum asinh
#define atan2gnum atan2
#define atangnum atan
#define atanhgnum atanh
#define ceilgnum ceil
#define powgnum pow
#define hypotgnum hypot
#define cosgnum cos
#define coshgnum cosh
#define erfcgnum erfc
#define erfgnum erf
#define expgnum exp
#define expm1gnum expm1
#define loggnum log
#define floorgnum floor
#define fmodgnum fmod
#define frexpgnum frexp
#define gnumabs fabs
#define hypotgnum hypot
#define isnangnum isnan
#define ldexpgnum ldexp
#define log10gnum log10
#define log1pgnum log1p
#define loggnum log
#define modfgnum modf
#define powgnum pow
#define singnum sin
#define cosgnum cos
#define tangnum tan
#define asingnum asin
#define acosgnum acos
#define atangnum atan
#define atan2gnum atan2
#define erfgnum erf
#define erfcgnum erfc
#define yngnum yn
#define isnangnum isnan
#define sinhgnum sinh
#define coshgnum cosh
#define sqrtgnum sqrt
#define strtognum strtod
#define tangnum tan
#define tanhgnum tanh
#define asinhgnum asinh
#define acoshgnum acosh
#define atanhgnum atanh
#define yngnum yn
/* What a circus! */
#ifdef HAVE_FINITE
......
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