s_remquo.c 861 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* Copyright (C) 2002 by Red Hat, Incorporated. All rights reserved.
  2. *
  3. * Permission to use, copy, modify, and distribute this software
  4. * is freely granted, provided that this notice is preserved.
  5. */
  6. #include "math.h"
  7. #include "math_private.h"
  8. #ifdef __STDC__
  9. double remquo(double x, double y, int *quo) /* wrapper remquo */
  10. #else
  11. double remquo(x,y,quo) /* wrapper remquo */
  12. double x,y;
  13. int *quo;
  14. #endif
  15. {
  16. int signx, signy, signres;
  17. int mswx;
  18. int mswy;
  19. double x_over_y;
  20. GET_HIGH_WORD(mswx, x);
  21. GET_HIGH_WORD(mswy, y);
  22. signx = (mswx & 0x80000000) >> 31;
  23. signy = (mswy & 0x80000000) >> 31;
  24. signres = (signx ^ signy) ? -1 : 1;
  25. x_over_y = fabs(x / y);
  26. *quo = signres * (lrint(x_over_y) & 0x7f);
  27. return remainder(x,y);
  28. }
  29. libm_hidden_def(remquo)