glibc/sysdeps/libm-ieee754/s_remquo.c
Ulrich Drepper 5649a1d60d Update.
1997-06-04 20:57  Ulrich Drepper  <drepper@cygnus.com>

	* manual/string.texi: Add comments to discourage use of index and
	rindex.
	(strtok, strsep): Apply function on copy of the strings in example.
	(l64a): Add example.

	* posix/unistd.h: Correct value for _POSIX_VERSION.

	* sunrpc/Makefile (defines): Remove definition.

	* sysdeps/ieee754/nan.h: Correct typo.

1997-06-04 10:50  Fila Kolodny  <fila@ibi.com>

	* posix/unistd.h: Add definition of __fchdir corresponding to fchdir.

	* login/utmp_daemon.c: Correct location of utmpd.h.

1997-06-03 19:16  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* Makerules: Rename $(common-objpfx)distinfo-$(subdir) to
	$(objpfx)distinfo.
	* rpm/Makefile (distinfo): Adapted.

1997-06-03 18:32  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* rpm/Makefile (install-slib): Collect shared libraries here
	instead of in install-lib, including libc.
	(instvars): Add slib.

1997-06-03 18:23  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* login/Makefile (libutil-routines): Add updwtmp.

1997-06-03 16:16  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* monetary.h: New file, needed for localedata/tst-fmon.c.

1997-06-02 20:31  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* math/libm-test.c (cpow_test): Add epsilon for long double in
	test for 2^10.
	(identities): Add epsilon for float in second identity test.

	* sysdeps/m68k/huge_val.h: Change GCC's HUGE_VAL{,F,L} to use
	DI and SI mode integers instead of bytes.  Fix value of HUGE_VALL.

	* sysdeps/m68k/nan.h: New file.

	* sysdeps/m68k/fpu/__math.h (isgreater, isgreaterequal, isless,
	islessequal, islessgreater, isunordered): Fix assembler syntax.

	* sysdeps/m68k/fpu/fraiseexcpt.c: Do it right so that gcc doesn't
	optimize out the operations.

	* sysdeps/libm-ieee754/s_nan.c: Use NaN macro instead of static
	constant.
	* sysdeps/libm-ieee754/s_nanf.c: Likewise.
	* sysdeps/libm-ieee754/s_nanl.c: Likewise.

	* math/carg.c [NO_LONG_DOUBLE]: Add alias for long double
	function.
	* sysdeps/libm-ieee754/s_erf.c: Likewise.
	* sysdeps/libm-ieee754/s_fdim.c: Likewise.
	* sysdeps/libm-ieee754/s_fmax.c: Likewise.
	* sysdeps/libm-ieee754/s_fmin.c: Likewise.
	* sysdeps/libm-ieee754/s_log2.c: Likewise.
	* sysdeps/libm-ieee754/s_nan.c: Likewise.
	* sysdeps/libm-ieee754/s_remquo.c: Likewise.
1997-06-04 19:05:38 +00:00

117 lines
2.4 KiB
C

/* Compute remainder and a congruent to the quotient.
Copyright (C) 1997 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with the GNU C Library; see the file COPYING.LIB. If not,
write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA. */
#include <math.h>
#include "math_private.h"
static const double zero = 0.0;
double
__remquo (double x, double y, int *quo)
{
int32_t hx,hy;
u_int32_t sx,lx,ly;
int cquo, qs;
EXTRACT_WORDS (hx, lx, x);
EXTRACT_WORDS (hy, ly, y);
sx = hx & 0x80000000;
qs = sx ^ (hy & 0x80000000);
hy &= 0x7fffffff;
hx &= 0x7fffffff;
/* Purge off exception values. */
if ((hy | ly) == 0)
return (x * y) / (x * y); /* y = 0 */
if ((hx >= 0x7ff00000) /* x not finite */
|| ((hy >= 0x7ff00000) /* p is NaN */
&& (((hy - 0x7ff00000) | ly) != 0)))
return (x * y) / (x * y);
if (hy <= 0x7fbfffff)
x = __ieee754_fmod (x, 8 * y); /* now x < 8y */
if (((hx - hy) | (lx - ly)) == 0)
{
*quo = qs ? -1 : 1;
return zero * x;
}
x = fabs (x);
y = fabs (y);
cquo = 0;
if (x >= 4 * y)
{
x -= 4 * y;
cquo += 4;
}
if (x >= 2 * y)
{
x -= 2 * y;
cquo += 2;
}
if (x >= y)
{
x -= y;
++cquo;
}
if (hy < 0x00200000)
{
if (x + x > y)
{
x -= y;
if (x + x >= y)
{
x -= y;
++cquo;
}
}
}
else
{
double y_half = 0.5 * y;
if (x > y_half)
{
x -= y;
if (x >= y_half)
{
x -= y;
++cquo;
}
}
}
*quo = qs ? -cquo : cquo;
if (sx)
x = -x;
return x;
}
weak_alias (__remquo, remquo)
#ifdef NO_LONG_DOUBLE
strong_alias (__remquo, __remquol)
weak_alias (__remquo, remquol)
#endif