home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / LIBC / LIBC-4.6 / LIBC-4 / libc-linux / sysdeps / linux / i386 / math / modfl.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-26  |  716 b   |  43 lines

  1. #include "mathl.h"
  2.  
  3. #ifndef SOFT_387
  4.  
  5. long double
  6. modfl(long double x, long double *iptr)
  7. {
  8.   long double tmp;
  9.   volatile short cw, cwtmp;
  10.  
  11.   __asm__ volatile ("fnstcw %0" : "=m" (cw) : );
  12.   cwtmp = cw | 0xc00;
  13.   __asm__ volatile ("fldcw %0" : : "m" (cwtmp));
  14.   __asm__ volatile ("frndint" : "=t" (tmp) : "0" (x));
  15.   __asm__ volatile ("fldcw %0" : : "m" (cw));
  16.   *iptr = tmp;
  17.  
  18.   return (x - tmp);
  19. }
  20.  
  21. #else
  22.  
  23. long double fabsl(), floorl();
  24.  
  25. /*  Returns fractional part of d, stores integer part in *integ
  26.  */
  27. long double modf(long double d, long double *integ)
  28. {
  29.   long double i, f;
  30.  
  31.   f = fabsl(d);
  32.   i = floorl(f);
  33.   f -= i;
  34.   if( d < 0.0 )
  35.     {
  36.       i = -i;
  37.       f = -f;
  38.     }
  39.   *integ = i;
  40.   return f;
  41. }
  42. #endif
  43.