/******************************************************************\
* <math-68881.h> last modified: 18 May 1989. *
* Copyright (C) 1989 by Matthew Self. *
* You may freely distribute verbatim copies of this software *
* provided that this copyright notice is retained in all copies. *
* You may distribute modifications to this software under the *
* conditions above if you also clearly note such modifications *
* with their author and date. *
* Note: errno is not set to EDOM when domain errors occur for *
* most of these functions. Rather, it is assumed that the *
* 68881's OPERR exception will be enabled and handled *
* appropriately by the operating system. Similarly, overflow *
* and underflow do not set errno to ERANGE. *
* Send bugs to Matthew Self (self@bayes.arc.nasa.gov). *
\******************************************************************/
/* Modified by Richard Stallman, November 1990, to initialize HUGE_VAL
December 1989, add parens around `&' in pow. */
/* The Sun assembler fails to handle the hex constant in the usual defn. */
static union { int i[2]; double d; } u = { {0x7ff00000, 0} }; \
__asm ("fmove%.d #0x7ff0000000000000,%0" /* Infinity */ \
__inline
static const double sin (double x
)
__inline
static const double cos (double x
)
__inline
static const double tan (double x
)
__inline
static const double asin (double x
)
__inline
static const double acos (double x
)
__inline
static const double atan (double x
)
__inline
static const double atan2 (double y
, double x
)
__asm ("fmovecr%.x %#0,%0" /* extended precision pi */
__asm ("fscale%.b %#-1,%0" /* no loss of accuracy */
return pi_over_2
- atan (x
/ y
);
return - pi_over_2
- atan (x
/ y
);
return pi
+ atan (y
/ x
);
return pi_over_2
- atan (x
/ y
);
return - pi
+ atan (y
/ x
);
return - pi_over_2
- atan (x
/ y
);
__asm ("fmove%.d %#0rnan,%0" /* quiet NaN */
__inline
static const double sinh (double x
)
__inline
static const double cosh (double x
)
__inline
static const double tanh (double x
)
__inline
static const double atanh (double x
)
__inline
static const double exp (double x
)
__inline
static const double expm1 (double x
)
__asm ("fetoxm1%.x %1,%0"
__inline
static const double log (double x
)
__inline
static const double log1p (double x
)
__asm ("flognp1%.x %1,%0"
__inline
static const double log10 (double x
)
__inline
static const double sqrt (double x
)
__inline
static const double pow (const double x
, const double y
)
return exp (y
* log (x
));
__asm ("fmove%.d %#0rnan,%0" /* quiet NaN */
: "=f" (temp
) /* integer-valued float */
if ((i
& 1) == 0) /* even */
return exp (y
* log (x
));
return - exp (y
* log (x
));
__asm ("fmove%.d %#0rnan,%0" /* quiet NaN */
__inline
static const double fabs (double x
)
__inline
static const double ceil (double x
)
int rounding_mode
, round_up
;
__asm
volatile ("fmove%.l fpcr,%0"
round_up
= rounding_mode
| 0x30;
__asm
volatile ("fmove%.l %0,fpcr"
__asm
volatile ("fint%.x %1,%0"
__asm
volatile ("fmove%.l %0,fpcr"
: "dmi" (rounding_mode
));
__inline
static const double floor (double x
)
int rounding_mode
, round_down
;
__asm
volatile ("fmove%.l fpcr,%0"
round_down
= (rounding_mode
& ~0x10)
__asm
volatile ("fmove%.l %0,fpcr"
__asm
volatile ("fint%.x %1,%0"
__asm
volatile ("fmove%.l %0,fpcr"
: "dmi" (rounding_mode
));
__inline
static const double rint (double x
)
int rounding_mode
, round_nearest
;
__asm
volatile ("fmove%.l fpcr,%0"
round_nearest
= rounding_mode
& ~0x30;
__asm
volatile ("fmove%.l %0,fpcr"
: "dmi" (round_nearest
));
__asm
volatile ("fint%.x %1,%0"
__asm
volatile ("fmove%.l %0,fpcr"
: "dmi" (rounding_mode
));
__inline
static const double fmod (double x
, double y
)
__inline
static const double drem (double x
, double y
)
__inline
static const double scalb (double x
, int n
)
__inline
static double logb (double x
)
__asm ("fgetexp%.x %1,%0"
__inline
static const double ldexp (double x
, int n
)
__inline
static double frexp (double x
, int *exp
)
__asm ("fgetexp%.x %1,%0"
: "=f" (float_exponent
) /* integer-valued float */
int_exponent
= (int) float_exponent
;
__asm ("fgetman%.x %1,%0"
: "=f" (mantissa
) /* 1.0 <= mantissa < 2.0 */
__asm ("fscale%.b %#-1,%0"
: "=f" (mantissa
) /* mantissa /= 2.0 */
__inline
static double modf (double x
, double *ip
)
: "=f" (temp
) /* integer-valued float */