3 #ifdef X87_DOUBLE_ROUNDING
4 /* On x86 platforms using an x87 FPU, this function is called from the
5 Py_FORCE_DOUBLE macro (defined in pymath.h) to force a floating-point
6 number out of an 80-bit x87 FPU register and into a 64-bit memory location,
7 thus rounding from extended precision to double precision. */
8 double _Py_force_double(double x)
16 #ifdef HAVE_GCC_ASM_FOR_X87
18 /* inline assembly for getting and setting the 387 FPU control word on
21 unsigned short _Py_get_387controlword(void) {
23 __asm__ __volatile__ ("fnstcw %0" : "=m" (cw));
27 void _Py_set_387controlword(unsigned short cw) {
28 __asm__ __volatile__ ("fldcw %0" : : "m" (cw));
35 double hypot(double x, double y)
50 return x*sqrt(1.+yx*yx);
53 #endif /* HAVE_HYPOT */
57 copysign(double x, double y)
59 /* use atan2 to distinguish -0. from 0. */
60 if (y > 0. || (y == 0. && atan2(y, -1.) > 0.)) {
66 #endif /* HAVE_COPYSIGN */
77 return copysign(y, x);
79 #endif /* HAVE_ROUND */