fif4.c 914 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /*
  2. (c) copyright 1988 by the Vrije Universiteit, Amsterdam, The Netherlands.
  3. See the copyright notice in the ACK home directory, in the file "Copyright".
  4. */
  5. /* $Id$ */
  6. /*
  7. MULTIPLY AND DISMEMBER PARTS (FIF 4)
  8. */
  9. #include "FP_types.h"
  10. #include "FP_shift.h"
  11. void
  12. fif4(p,x,y)
  13. SINGLE x,y;
  14. struct fif4_returns *p;
  15. {
  16. EXTEND e1,e2;
  17. extend(&y,&e1,sizeof(SINGLE));
  18. extend(&x,&e2,sizeof(SINGLE));
  19. /* do a multiply */
  20. mul_ext(&e1,&e2);
  21. e2 = e1;
  22. compact(&e2,&y,sizeof(SINGLE));
  23. if (e1.exp < 0) {
  24. p->ipart = 0;
  25. p->fpart = y;
  26. return;
  27. }
  28. if (e1.exp > 30 - SGL_M1LEFT) {
  29. p->ipart = y;
  30. p->fpart = 0;
  31. return;
  32. }
  33. b64_sft(&e1.mantissa, 63 - e1.exp);
  34. b64_sft(&e1.mantissa, e1.exp - 63); /* "loose" low order bits */
  35. compact(&e1,&(p->ipart),sizeof(SINGLE));
  36. extend(&(p->ipart), &e2, sizeof(SINGLE));
  37. extend(&y, &e1, sizeof(SINGLE));
  38. sub_ext(&e1, &e2);
  39. compact(&e1, &(p->fpart), sizeof(SINGLE));
  40. }