diff options
Diffstat (limited to 'newlib/libm/mathfp')
-rw-r--r-- | newlib/libm/mathfp/Makefile.am | 9 | ||||
-rw-r--r-- | newlib/libm/mathfp/Makefile.in | 49 | ||||
-rw-r--r-- | newlib/libm/mathfp/mathfp.tex | 37 | ||||
-rw-r--r-- | newlib/libm/mathfp/s_atangent.c | 4 | ||||
-rw-r--r-- | newlib/libm/mathfp/s_frexp.c | 21 | ||||
-rw-r--r-- | newlib/libm/mathfp/s_infconst.c | 15 | ||||
-rw-r--r-- | newlib/libm/mathfp/s_isinf.c | 37 | ||||
-rw-r--r-- | newlib/libm/mathfp/s_isnan.c | 125 | ||||
-rw-r--r-- | newlib/libm/mathfp/s_ldexp.c | 2 | ||||
-rw-r--r-- | newlib/libm/mathfp/s_logarithm.c | 5 | ||||
-rw-r--r-- | newlib/libm/mathfp/s_mathcnst.c | 6 | ||||
-rw-r--r-- | newlib/libm/mathfp/s_pow.c | 5 | ||||
-rw-r--r-- | newlib/libm/mathfp/sf_atangent.c | 4 | ||||
-rw-r--r-- | newlib/libm/mathfp/sf_frexp.c | 21 | ||||
-rw-r--r-- | newlib/libm/mathfp/sf_isinf.c | 48 | ||||
-rw-r--r-- | newlib/libm/mathfp/sf_isnan.c | 48 | ||||
-rw-r--r-- | newlib/libm/mathfp/sf_pow.c | 5 | ||||
-rw-r--r-- | newlib/libm/mathfp/w_jn.c | 2 |
18 files changed, 345 insertions, 98 deletions
diff --git a/newlib/libm/mathfp/Makefile.am b/newlib/libm/mathfp/Makefile.am index e529022a6..92688c43d 100644 --- a/newlib/libm/mathfp/Makefile.am +++ b/newlib/libm/mathfp/Makefile.am @@ -16,12 +16,12 @@ src = s_acos.c s_frexp.c s_mathcnst.c \ s_sincos.c \ s_atangent.c s_logarithm.c \ s_sineh.c \ - s_ceil.c \ + s_ceil.c s_isnan.c s_isinf.c \ e_acosh.c e_atanh.c e_remainder.c \ er_gamma.c er_lgamma.c \ s_erf.c e_j0.c e_j1.c w_jn.c e_hypot.c \ w_cabs.c w_drem.c s_asinh.c s_fmod.c \ - e_scalb.c s_signif.c \ + e_scalb.c s_infconst.c s_signif.c \ s_exp2.c s_tgamma.c fsrc = sf_ceil.c \ @@ -36,6 +36,7 @@ fsrc = sf_ceil.c \ sf_sincos.c \ sf_atangent.c sf_logarithm.c sf_sineh.c \ sf_log.c sf_sineh.c \ + sf_isnan.c sf_isinf.c \ ef_acosh.c ef_atanh.c ef_remainder.c \ erf_gamma.c erf_lgamma.c \ sf_erf.c ef_j0.c ef_j1.c wf_jn.c ef_hypot.c \ @@ -75,6 +76,7 @@ chobj = eacosh.def \ sfloor.def \ sfmod.def \ sfrexp.def \ + sisnan.def \ sldexp.def \ slog10.def \ slogarithm.def \ @@ -158,6 +160,9 @@ sfmod.def: s_fmod.c sfrexp.def: s_frexp.c $(CHEW) < $(srcdir)/s_frexp.c >$@ 2>/dev/null touch stmp-def +sisnan.def: s_isnan.c + $(CHEW) < $(srcdir)/s_isnan.c >$@ 2>/dev/null + touch stmp-def sldexp.def: s_ldexp.c $(CHEW) < $(srcdir)/s_ldexp.c >$@ 2>/dev/null touch stmp-def diff --git a/newlib/libm/mathfp/Makefile.in b/newlib/libm/mathfp/Makefile.in index b11e8130f..8157e1273 100644 --- a/newlib/libm/mathfp/Makefile.in +++ b/newlib/libm/mathfp/Makefile.in @@ -98,10 +98,10 @@ AUTOMAKE_OPTIONS = cygnus INCLUDES = -I$(srcdir)/../common $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS) -src = s_acos.c s_frexp.c s_mathcnst.c s_cos.c s_sinh.c s_asin.c s_asine.c s_cosh.c s_ispos.c s_numtest.c s_sqrt.c s_exp.c s_ldexp.c s_pow.c s_tan.c s_atan.c s_atan2.c s_fabs.c s_log.c s_tanh.c s_log10.c s_sin.c s_floor.c s_sine.c s_sincos.c s_atangent.c s_logarithm.c s_sineh.c s_ceil.c e_acosh.c e_atanh.c e_remainder.c er_gamma.c er_lgamma.c s_erf.c e_j0.c e_j1.c w_jn.c e_hypot.c w_cabs.c w_drem.c s_asinh.c s_fmod.c e_scalb.c s_signif.c s_exp2.c s_tgamma.c +src = s_acos.c s_frexp.c s_mathcnst.c s_cos.c s_sinh.c s_asin.c s_asine.c s_cosh.c s_ispos.c s_numtest.c s_sqrt.c s_exp.c s_ldexp.c s_pow.c s_tan.c s_atan.c s_atan2.c s_fabs.c s_log.c s_tanh.c s_log10.c s_sin.c s_floor.c s_sine.c s_sincos.c s_atangent.c s_logarithm.c s_sineh.c s_ceil.c s_isnan.c s_isinf.c e_acosh.c e_atanh.c e_remainder.c er_gamma.c er_lgamma.c s_erf.c e_j0.c e_j1.c w_jn.c e_hypot.c w_cabs.c w_drem.c s_asinh.c s_fmod.c e_scalb.c s_infconst.c s_signif.c s_exp2.c s_tgamma.c -fsrc = sf_ceil.c sf_acos.c sf_frexp.c sf_cos.c sf_sinh.c sf_asine.c sf_cosh.c sf_ispos.c sf_numtest.c sf_sqrt.c sf_asin.c sf_exp.c sf_ldexp.c sf_pow.c sf_tan.c sf_atan2.c sf_fabs.c sf_tanh.c sf_atan.c sf_log10.c sf_sin.c sf_floor.c sf_sine.c sf_sincos.c sf_atangent.c sf_logarithm.c sf_sineh.c sf_log.c sf_sineh.c ef_acosh.c ef_atanh.c ef_remainder.c erf_gamma.c erf_lgamma.c sf_erf.c ef_j0.c ef_j1.c wf_jn.c ef_hypot.c wf_cabs.c wf_drem.c sf_asinh.c sf_fmod.c ef_scalb.c sf_signif.c sf_exp2.c sf_tgamma.c +fsrc = sf_ceil.c sf_acos.c sf_frexp.c sf_cos.c sf_sinh.c sf_asine.c sf_cosh.c sf_ispos.c sf_numtest.c sf_sqrt.c sf_asin.c sf_exp.c sf_ldexp.c sf_pow.c sf_tan.c sf_atan2.c sf_fabs.c sf_tanh.c sf_atan.c sf_log10.c sf_sin.c sf_floor.c sf_sine.c sf_sincos.c sf_atangent.c sf_logarithm.c sf_sineh.c sf_log.c sf_sineh.c sf_isnan.c sf_isinf.c ef_acosh.c ef_atanh.c ef_remainder.c erf_gamma.c erf_lgamma.c sf_erf.c ef_j0.c ef_j1.c wf_jn.c ef_hypot.c wf_cabs.c wf_drem.c sf_asinh.c sf_fmod.c ef_scalb.c sf_signif.c sf_exp2.c sf_tgamma.c libmathfp_la_LDFLAGS = -Xcompiler -nostdlib @@ -113,7 +113,7 @@ libmathfp_la_LDFLAGS = -Xcompiler -nostdlib @USE_LIBTOOL_FALSE@noinst_LIBRARIES = lib.a @USE_LIBTOOL_FALSE@lib_a_SOURCES = $(src) $(fsrc) -chobj = eacosh.def eatanh.def ehypot.def eremainder.def erlgamma.def sacos.def sasine.def sasinh.def satan.def satan2.def satangent.def scosh.def serf.def sexp.def sfabs.def sfloor.def sfmod.def sfrexp.def sldexp.def slog10.def slogarithm.def spow.def ssine.def ssineh.def ssqrt.def stan.def stanh.def wjn.def +chobj = eacosh.def eatanh.def ehypot.def eremainder.def erlgamma.def sacos.def sasine.def sasinh.def satan.def satan2.def satangent.def scosh.def serf.def sexp.def sfabs.def sfloor.def sfmod.def sfrexp.def sisnan.def sldexp.def slog10.def slogarithm.def spow.def ssine.def ssineh.def ssqrt.def stan.def stanh.def wjn.def SUFFIXES = .def @@ -143,19 +143,21 @@ lib_a_LIBADD = @USE_LIBTOOL_FALSE@s_sin.$(OBJEXT) s_floor.$(OBJEXT) s_sine.$(OBJEXT) \ @USE_LIBTOOL_FALSE@s_sincos.$(OBJEXT) s_atangent.$(OBJEXT) \ @USE_LIBTOOL_FALSE@s_logarithm.$(OBJEXT) s_sineh.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@s_ceil.$(OBJEXT) e_acosh.$(OBJEXT) e_atanh.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_ceil.$(OBJEXT) s_isnan.$(OBJEXT) s_isinf.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@e_acosh.$(OBJEXT) e_atanh.$(OBJEXT) \ @USE_LIBTOOL_FALSE@e_remainder.$(OBJEXT) er_gamma.$(OBJEXT) \ @USE_LIBTOOL_FALSE@er_lgamma.$(OBJEXT) s_erf.$(OBJEXT) e_j0.$(OBJEXT) \ @USE_LIBTOOL_FALSE@e_j1.$(OBJEXT) w_jn.$(OBJEXT) e_hypot.$(OBJEXT) \ @USE_LIBTOOL_FALSE@w_cabs.$(OBJEXT) w_drem.$(OBJEXT) s_asinh.$(OBJEXT) \ @USE_LIBTOOL_FALSE@s_fmod.$(OBJEXT) e_scalb.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@s_signif.$(OBJEXT) s_exp2.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@s_tgamma.$(OBJEXT) sf_ceil.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@sf_acos.$(OBJEXT) sf_frexp.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@sf_cos.$(OBJEXT) sf_sinh.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@sf_asine.$(OBJEXT) sf_cosh.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@sf_ispos.$(OBJEXT) sf_numtest.$(OBJEXT) \ -@USE_LIBTOOL_FALSE@sf_sqrt.$(OBJEXT) sf_asin.$(OBJEXT) sf_exp.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_infconst.$(OBJEXT) s_signif.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@s_exp2.$(OBJEXT) s_tgamma.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@sf_ceil.$(OBJEXT) sf_acos.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@sf_frexp.$(OBJEXT) sf_cos.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@sf_sinh.$(OBJEXT) sf_asine.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@sf_cosh.$(OBJEXT) sf_ispos.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@sf_numtest.$(OBJEXT) sf_sqrt.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@sf_asin.$(OBJEXT) sf_exp.$(OBJEXT) \ @USE_LIBTOOL_FALSE@sf_ldexp.$(OBJEXT) sf_pow.$(OBJEXT) sf_tan.$(OBJEXT) \ @USE_LIBTOOL_FALSE@sf_atan2.$(OBJEXT) sf_fabs.$(OBJEXT) \ @USE_LIBTOOL_FALSE@sf_tanh.$(OBJEXT) sf_atan.$(OBJEXT) \ @@ -164,6 +166,7 @@ lib_a_LIBADD = @USE_LIBTOOL_FALSE@sf_sincos.$(OBJEXT) sf_atangent.$(OBJEXT) \ @USE_LIBTOOL_FALSE@sf_logarithm.$(OBJEXT) sf_sineh.$(OBJEXT) \ @USE_LIBTOOL_FALSE@sf_log.$(OBJEXT) sf_sineh.$(OBJEXT) \ +@USE_LIBTOOL_FALSE@sf_isnan.$(OBJEXT) sf_isinf.$(OBJEXT) \ @USE_LIBTOOL_FALSE@ef_acosh.$(OBJEXT) ef_atanh.$(OBJEXT) \ @USE_LIBTOOL_FALSE@ef_remainder.$(OBJEXT) erf_gamma.$(OBJEXT) \ @USE_LIBTOOL_FALSE@erf_lgamma.$(OBJEXT) sf_erf.$(OBJEXT) \ @@ -182,10 +185,11 @@ libmathfp_la_LIBADD = @USE_LIBTOOL_TRUE@s_ldexp.lo s_pow.lo s_tan.lo s_atan.lo s_atan2.lo \ @USE_LIBTOOL_TRUE@s_fabs.lo s_log.lo s_tanh.lo s_log10.lo s_sin.lo \ @USE_LIBTOOL_TRUE@s_floor.lo s_sine.lo s_sincos.lo s_atangent.lo \ -@USE_LIBTOOL_TRUE@s_logarithm.lo s_sineh.lo s_ceil.lo e_acosh.lo \ -@USE_LIBTOOL_TRUE@e_atanh.lo e_remainder.lo er_gamma.lo er_lgamma.lo \ -@USE_LIBTOOL_TRUE@s_erf.lo e_j0.lo e_j1.lo w_jn.lo e_hypot.lo w_cabs.lo \ -@USE_LIBTOOL_TRUE@w_drem.lo s_asinh.lo s_fmod.lo e_scalb.lo s_signif.lo \ +@USE_LIBTOOL_TRUE@s_logarithm.lo s_sineh.lo s_ceil.lo s_isnan.lo \ +@USE_LIBTOOL_TRUE@s_isinf.lo e_acosh.lo e_atanh.lo e_remainder.lo \ +@USE_LIBTOOL_TRUE@er_gamma.lo er_lgamma.lo s_erf.lo e_j0.lo e_j1.lo \ +@USE_LIBTOOL_TRUE@w_jn.lo e_hypot.lo w_cabs.lo w_drem.lo s_asinh.lo \ +@USE_LIBTOOL_TRUE@s_fmod.lo e_scalb.lo s_infconst.lo s_signif.lo \ @USE_LIBTOOL_TRUE@s_exp2.lo s_tgamma.lo sf_ceil.lo sf_acos.lo \ @USE_LIBTOOL_TRUE@sf_frexp.lo sf_cos.lo sf_sinh.lo sf_asine.lo \ @USE_LIBTOOL_TRUE@sf_cosh.lo sf_ispos.lo sf_numtest.lo sf_sqrt.lo \ @@ -193,12 +197,12 @@ libmathfp_la_LIBADD = @USE_LIBTOOL_TRUE@sf_atan2.lo sf_fabs.lo sf_tanh.lo sf_atan.lo \ @USE_LIBTOOL_TRUE@sf_log10.lo sf_sin.lo sf_floor.lo sf_sine.lo \ @USE_LIBTOOL_TRUE@sf_sincos.lo sf_atangent.lo sf_logarithm.lo \ -@USE_LIBTOOL_TRUE@sf_sineh.lo sf_log.lo sf_sineh.lo ef_acosh.lo \ -@USE_LIBTOOL_TRUE@ef_atanh.lo ef_remainder.lo erf_gamma.lo \ -@USE_LIBTOOL_TRUE@erf_lgamma.lo sf_erf.lo ef_j0.lo ef_j1.lo wf_jn.lo \ -@USE_LIBTOOL_TRUE@ef_hypot.lo wf_cabs.lo wf_drem.lo sf_asinh.lo \ -@USE_LIBTOOL_TRUE@sf_fmod.lo ef_scalb.lo sf_signif.lo sf_exp2.lo \ -@USE_LIBTOOL_TRUE@sf_tgamma.lo +@USE_LIBTOOL_TRUE@sf_sineh.lo sf_log.lo sf_sineh.lo sf_isnan.lo \ +@USE_LIBTOOL_TRUE@sf_isinf.lo ef_acosh.lo ef_atanh.lo ef_remainder.lo \ +@USE_LIBTOOL_TRUE@erf_gamma.lo erf_lgamma.lo sf_erf.lo ef_j0.lo \ +@USE_LIBTOOL_TRUE@ef_j1.lo wf_jn.lo ef_hypot.lo wf_cabs.lo wf_drem.lo \ +@USE_LIBTOOL_TRUE@sf_asinh.lo sf_fmod.lo ef_scalb.lo sf_signif.lo \ +@USE_LIBTOOL_TRUE@sf_exp2.lo sf_tgamma.lo CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -494,6 +498,9 @@ sfmod.def: s_fmod.c sfrexp.def: s_frexp.c $(CHEW) < $(srcdir)/s_frexp.c >$@ 2>/dev/null touch stmp-def +sisnan.def: s_isnan.c + $(CHEW) < $(srcdir)/s_isnan.c >$@ 2>/dev/null + touch stmp-def sldexp.def: s_ldexp.c $(CHEW) < $(srcdir)/s_ldexp.c >$@ 2>/dev/null touch stmp-def diff --git a/newlib/libm/mathfp/mathfp.tex b/newlib/libm/mathfp/mathfp.tex index 0b9f08557..6286405a0 100644 --- a/newlib/libm/mathfp/mathfp.tex +++ b/newlib/libm/mathfp/mathfp.tex @@ -25,7 +25,7 @@ Since the error handling code calls @code{fputs}, the mathematical subroutines require stubs or minimal implementations for the same list of OS subroutines as @code{fputs}: @code{close}, @code{fstat}, @code{isatty}, @code{lseek}, @code{read}, @code{sbrk}, @code{write}. -@xref{syscalls,,System Calls, libc.info, The Red Hat newlib C Library}, +@xref{syscalls,,System Calls, libc.info, The Cygnus C Support Library}, for a discussion and for sample minimal implementations of these support subroutines. @@ -139,12 +139,6 @@ The library is set to X/Open mode by default. @include mathfp/wjn.def @page -@include common/scbrt.def - -@page -@include common/scopysign.def - -@page @include mathfp/scosh.def @page @@ -154,9 +148,6 @@ The library is set to X/Open mode by default. @include mathfp/sexp.def @page -@include common/sexpm1.def - -@page @include mathfp/sfabs.def @page @@ -175,13 +166,7 @@ The library is set to X/Open mode by default. @include mathfp/ehypot.def @page -@include common/silogb.def - -@page -@include common/sinfinity.def - -@page -@include common/sisnan.def +@include mathfp/sisnan.def @page @include mathfp/sldexp.def @@ -193,30 +178,12 @@ The library is set to X/Open mode by default. @include mathfp/slog10.def @page -@include common/slog1p.def - -@page -@include common/smatherr.def - -@page -@include common/smodf.def - -@page -@include common/snan.def - -@page -@include common/snextafter.def - -@page @include mathfp/spow.def @page @include mathfp/eremainder.def @page -@include common/sscalbn.def - -@page @include mathfp/ssqrt.def @page diff --git a/newlib/libm/mathfp/s_atangent.c b/newlib/libm/mathfp/s_atangent.c index 0a7c4d2f8..981e1c822 100644 --- a/newlib/libm/mathfp/s_atangent.c +++ b/newlib/libm/mathfp/s_atangent.c @@ -197,9 +197,9 @@ _DEFUN (atangent, (double, double, double, int), if (arctan2) { - if (u < 0.0) + if (u < 0.0 || branch == 2) res = __PI - res; - if (v < 0.0) + if (v < 0.0 || branch == 1) res = -res; } else if (x < 0.0) diff --git a/newlib/libm/mathfp/s_frexp.c b/newlib/libm/mathfp/s_frexp.c index 54fa336c8..08611e9a7 100644 --- a/newlib/libm/mathfp/s_frexp.c +++ b/newlib/libm/mathfp/s_frexp.c @@ -82,17 +82,6 @@ double frexp (double d, int *exp) double f; __uint32_t hd, ld, hf, lf; - /* Check for special values. */ - switch (numtest (d)) - { - case NAN: - case INF: - errno = EDOM; - case 0: - *exp = 0; - return (d); - } - EXTRACT_WORDS (hd, ld, d); /* Get the exponent. */ @@ -105,6 +94,16 @@ double frexp (double d, int *exp) INSERT_WORDS (f, hf, lf); + /* Check for special values. */ + switch (numtest (f)) + { + case NAN: + case INF: + errno = EDOM; + *exp = 0; + return (f); + } + return (f); } diff --git a/newlib/libm/mathfp/s_infconst.c b/newlib/libm/mathfp/s_infconst.c new file mode 100644 index 000000000..e6b86d497 --- /dev/null +++ b/newlib/libm/mathfp/s_infconst.c @@ -0,0 +1,15 @@ +/* Infinity as a constant value. This is used for HUGE_VAL. + * Added by Cygnus Support. + */ + +#include "fdlibm.h" + +#ifndef _DOUBLE_IS_32BITS +#ifdef __IEEE_BIG_ENDIAN +const union __dmath __infinity[1] = {{ 0x7ff00000, 0 }}; +#else +const union __dmath __infinity[1] = {{ 0, 0x7ff00000 }}; +#endif +#else /* defined (_DOUBLE_IS_32BITS) */ +const union __dmath __infinity[1] = {{ 0x7f800000, 0 }}; +#endif /* defined (_DOUBLE_IS_32BITS) */ diff --git a/newlib/libm/mathfp/s_isinf.c b/newlib/libm/mathfp/s_isinf.c new file mode 100644 index 000000000..fe9f54799 --- /dev/null +++ b/newlib/libm/mathfp/s_isinf.c @@ -0,0 +1,37 @@ + +/* @(#)z_isinf.c 1.0 98/08/13 */ +/****************************************************************** + * isinf + * + * Input: + * x - pointer to a floating point value + * + * Output: + * An integer that indicates if the number is infinite. + * + * Description: + * This routine returns an integer that indicates if the number + * passed in is infinite (1) or is finite (0). + * + *****************************************************************/ + +#include "fdlibm.h" +#include "zmath.h" + +#ifndef _DOUBLE_IS_32BITS + +int isinf (double x) +{ + __uint32_t lx, hx; + int exp; + + EXTRACT_WORDS (hx, lx, x); + exp = (hx & 0x7ff00000) >> 20; + + if ((exp == 0x7ff) && ((hx & 0xf0000 || lx) == 0)) + return (1); + else + return (0); +} + +#endif /* _DOUBLE_IS_32BITS */ diff --git a/newlib/libm/mathfp/s_isnan.c b/newlib/libm/mathfp/s_isnan.c new file mode 100644 index 000000000..03cfeee59 --- /dev/null +++ b/newlib/libm/mathfp/s_isnan.c @@ -0,0 +1,125 @@ + +/* @(#)z_isnan.c 1.0 98/08/13 */ + +/* +FUNCTION + <<isnan>>,<<isnanf>>,<<isinf>>,<<isinff>>,<<finite>>,<<finitef>>---test +for exceptional numbers + +INDEX + isnan +INDEX + isinf +INDEX + finite + +INDEX + isnanf +INDEX + isinff +INDEX + finitef + +ANSI_SYNOPSIS + #include <ieeefp.h> + int isnan(double <[arg]>); + int isinf(double <[arg]>); + int finite(double <[arg]>); + int isnanf(float <[arg]>); + int isinff(float <[arg]>); + int finitef(float <[arg]>); + +TRAD_SYNOPSIS + #include <ieeefp.h> + int isnan(<[arg]>) + double <[arg]>; + int isinf(<[arg]>) + double <[arg]>; + int finite(<[arg]>); + double <[arg]>; + int isnanf(<[arg]>); + float <[arg]>; + int isinff(<[arg]>); + float <[arg]>; + int finitef(<[arg]>); + float <[arg]>; + + +DESCRIPTION + These functions provide information on the floating-point + argument supplied. + + There are five major number formats - + o+ + o zero + a number which contains all zero bits. + o subnormal + Is used to represent number with a zero exponent, but a nonzero fract +ion. + o normal + A number with an exponent, and a fraction + o infinity + A number with an all 1's exponent and a zero fraction. + o NAN + A number with an all 1's exponent and a nonzero fraction. + + o- + + <<isnan>> returns 1 if the argument is a nan. <<isinf>> + returns 1 if the argument is infinity. <<finite>> returns 1 if the + argument is zero, subnormal or normal. + + The <<isnanf>>, <<isinff>> and <<finitef>> perform the same + operations as their <<isnan>>, <<isinf>> and <<finite>> + counterparts, but on single-precision floating-point numbers. + +QUICKREF + isnan - pure +QUICKREF + isinf - pure +QUICKREF + finite - pure +QUICKREF + isnan - pure +QUICKREF + isinf - pure +QUICKREF + finite - pure +*/ + + +/****************************************************************** + * isnan + * + * Input: + * x - pointer to a floating-point value + * + * Output: + * An integer that indicates if the number is NaN. + * + * Description: + * This routine returns an integer that indicates if the number + * passed in is NaN (1) or is finite (0). + * + *****************************************************************/ + +#include "fdlibm.h" +#include "zmath.h" + +#ifndef _DOUBLE_IS_32BITS + +int isnan (double x) +{ + __uint32_t lx, hx; + int exp; + + EXTRACT_WORDS (hx, lx, x); + exp = (hx & 0x7ff00000) >> 20; + + if ((exp == 0x7ff) && (hx & 0xf0000 || lx)) + return (1); + else + return (0); +} + +#endif /* _DOUBLE_IS_32BITS */ diff --git a/newlib/libm/mathfp/s_ldexp.c b/newlib/libm/mathfp/s_ldexp.c index 6da41284b..5ce2710ac 100644 --- a/newlib/libm/mathfp/s_ldexp.c +++ b/newlib/libm/mathfp/s_ldexp.c @@ -45,7 +45,7 @@ On underflow, <<ldexp>> and <<ldexpf>> return 0.0. On overflow, <<ldexp>> returns plus or minus <<HUGE_VAL>>. PORTABILITY -<<ldexp>> is ANSI. <<ldexpf>> is an extension. +<<ldexp>> is ANSI, <<ldexpf>> is an extension. */ diff --git a/newlib/libm/mathfp/s_logarithm.c b/newlib/libm/mathfp/s_logarithm.c index 3e07949c8..ee7c7069e 100644 --- a/newlib/libm/mathfp/s_logarithm.c +++ b/newlib/libm/mathfp/s_logarithm.c @@ -56,9 +56,8 @@ When <[x]> is negative, the returned value is <<-HUGE_VAL>> and <<matherr>>. PORTABILITY -<<log>> is ANSI. <<logf>> is an extension. - -<<log10>> is ANSI. <<log10f>> is an extension. +<<log>> is ANSI, <<logf>> is an extension. +<<log10>> is ANSI, <<log10f>> is an extension. */ diff --git a/newlib/libm/mathfp/s_mathcnst.c b/newlib/libm/mathfp/s_mathcnst.c index a847ee430..7865c7f78 100644 --- a/newlib/libm/mathfp/s_mathcnst.c +++ b/newlib/libm/mathfp/s_mathcnst.c @@ -12,13 +12,13 @@ ufloat z_hugeval_f = { 0x7f800000 }; ufloat z_infinity_f = { 0x7f800000 }; ufloat z_notanum_f = { 0xffd00000 }; -#ifdef __IEEE_BIG_ENDIAN +#ifdef ___IEEE_LITTLE_ENDIAN udouble z_hugeval = { 0x7ff00000, 0 }; udouble z_infinity = { 0x7ff00000, 0 }; udouble z_notanum = { 0xfff80000, 0 }; -#else /* __IEEE_LITTLE_ENDIAN */ +#else udouble z_hugeval = { 0, 0x7ff00000 }; udouble z_infinity = { 0, 0x7ff00000 }; udouble z_notanum = { 0, 0xfff80000 }; -#endif /* __IEEE_LITTLE_ENDIAN */ +#endif /* ___IEEE_LITTLE_ENDIAN */ diff --git a/newlib/libm/mathfp/s_pow.c b/newlib/libm/mathfp/s_pow.c index 90d9d0b5f..3514510d0 100644 --- a/newlib/libm/mathfp/s_pow.c +++ b/newlib/libm/mathfp/s_pow.c @@ -75,10 +75,9 @@ double pow (double x, double y) } } - if (x == 0.0) + if (x == 0.0 && y <= 0.0) { - if (y <= 0.0) - errno = EDOM; + errno = EDOM; } else if ((t = y * log (fabs (x))) >= BIGX) { diff --git a/newlib/libm/mathfp/sf_atangent.c b/newlib/libm/mathfp/sf_atangent.c index 7a8f0cebe..55a90063c 100644 --- a/newlib/libm/mathfp/sf_atangent.c +++ b/newlib/libm/mathfp/sf_atangent.c @@ -126,9 +126,9 @@ _DEFUN (atangentf, (float, float, float, int), if (arctan2) { - if (u < 0.0) + if (u < 0.0 || branch == 2) res = __PI - res; - if (v < 0.0) + if (v < 0.0 || branch == 1) res = -res; } else if (x < 0.0) diff --git a/newlib/libm/mathfp/sf_frexp.c b/newlib/libm/mathfp/sf_frexp.c index 7f25195c8..c2751f65c 100644 --- a/newlib/libm/mathfp/sf_frexp.c +++ b/newlib/libm/mathfp/sf_frexp.c @@ -24,17 +24,6 @@ float frexpf (float d, int *exp) float f; __int32_t wf, wd; - /* Check for special values. */ - switch (numtestf (d)) - { - case NAN: - case INF: - errno = EDOM; - case 0: - *exp = 0; - return (d); - } - GET_FLOAT_WORD (wd, d); /* Get the exponent. */ @@ -46,6 +35,16 @@ float frexpf (float d, int *exp) SET_FLOAT_WORD (f, wf); + /* Check for special values. */ + switch (numtestf (f)) + { + case NAN: + case INF: + errno = EDOM; + *exp = 0; + return (f); + } + return (f); } diff --git a/newlib/libm/mathfp/sf_isinf.c b/newlib/libm/mathfp/sf_isinf.c new file mode 100644 index 000000000..84ab3f71c --- /dev/null +++ b/newlib/libm/mathfp/sf_isinf.c @@ -0,0 +1,48 @@ + +/* @(#)z_isinff.c 1.0 98/08/13 */ +/****************************************************************** + * isinff + * + * Input: + * x - pointer to a floating point value + * + * Output: + * An integer that indicates if the number is infinite. + * + * Description: + * This routine returns an integer that indicates if the number + * passed in is infinite (1) or is finite (0). + * + *****************************************************************/ + +#include "fdlibm.h" +#include "zmath.h" + +int +_DEFUN (isinff, (float), + float x) +{ + __uint32_t wx; + int exp; + + GET_FLOAT_WORD (wx, x); + exp = (wx & 0x7f800000) >> 23; + + if ((exp == 0x7f8) && !(wx & 0xf0000)) + return (1); + else + return (0); +} + +#ifdef _DOUBLE_IS_32BITS + +int +_DEFUN (isinf, (double), + double x) +{ + return isinff ((float) x); +} + +#endif /* defined(_DOUBLE_IS_32BITS) */ + + diff --git a/newlib/libm/mathfp/sf_isnan.c b/newlib/libm/mathfp/sf_isnan.c new file mode 100644 index 000000000..ac557a6b8 --- /dev/null +++ b/newlib/libm/mathfp/sf_isnan.c @@ -0,0 +1,48 @@ + +/* @(#)z_isnanf.c 1.0 98/08/13 */ +/****************************************************************** + * isnanf + * + * Input: + * x - pointer to a floating point value + * + * Output: + * An integer that indicates if the number is NaN. + * + * Description: + * This routine returns an integer that indicates if the number + * passed in is NaN (1) or is finite (0). + * + *****************************************************************/ + +#include "fdlibm.h" +#include "zmath.h" + +int +_DEFUN (isnanf, (float), + float x) +{ + __int32_t wx; + int exp; + + GET_FLOAT_WORD (wx, x); + exp = (wx & 0x7f800000) >> 23; + + if ((exp == 0x7f8) && (wx & 0x7fffff)) + return (1); + else + return (0); +} + + +#ifdef _DOUBLE_IS_32BITS + +int +_DEFUN (isnan, (double), + double x) +{ + return isnanf((float) x); +} + +#endif /* defined(_DOUBLE_IS_32BITS) */ + diff --git a/newlib/libm/mathfp/sf_pow.c b/newlib/libm/mathfp/sf_pow.c index 489a71dd0..932e75dbb 100644 --- a/newlib/libm/mathfp/sf_pow.c +++ b/newlib/libm/mathfp/sf_pow.c @@ -29,10 +29,9 @@ float powf (float x, float y) } } - if (x == 0.0) + if (x == 0.0 && y <= 0.0) { - if (y <= 0.0) - errno = EDOM; + errno = EDOM; } else if ((t = y * log (fabsf (x))) >= BIGX) { diff --git a/newlib/libm/mathfp/w_jn.c b/newlib/libm/mathfp/w_jn.c index 14c2225f0..bd7878104 100644 --- a/newlib/libm/mathfp/w_jn.c +++ b/newlib/libm/mathfp/w_jn.c @@ -13,7 +13,7 @@ /* FUNCTION -<<jN>>, <<jNf>>, <<yN>>, <<yNf>>---Bessel functions +<<jN>>,<<jNf>>,<<yN>>,<<yNf>>---Bessel functions INDEX j0 |