fif8.c 1005 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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 8)
  8. */
  9. #include "FP_types.h"
  10. #include "FP_shift.h"
  11. void
  12. fif8(p,x,y)
  13. DOUBLE x,y;
  14. struct fif8_returns *p;
  15. {
  16. EXTEND e1,e2;
  17. extend(&y.d[0],&e1,sizeof(DOUBLE));
  18. extend(&x.d[0],&e2,sizeof(DOUBLE));
  19. /* do a multiply */
  20. mul_ext(&e1,&e2);
  21. e2 = e1;
  22. compact(&e2, &y.d[0], sizeof(DOUBLE));
  23. if (e1.exp < 0) {
  24. p->ipart.d[0] = 0;
  25. p->ipart.d[1] = 0;
  26. p->fpart = y;
  27. return;
  28. }
  29. if (e1.exp > 62 - DBL_M1LEFT) {
  30. p->ipart = y;
  31. p->fpart.d[0] = 0;
  32. p->fpart.d[1] = 0;
  33. return;
  34. }
  35. b64_sft(&e1.mantissa, 63 - e1.exp);
  36. b64_sft(&e1.mantissa, e1.exp - 63); /* "loose" low order bits */
  37. compact(&e1, &(p->ipart.d[0]), sizeof(DOUBLE));
  38. extend(&(p->ipart.d[0]), &e2, sizeof(DOUBLE));
  39. extend(&y.d[0], &e1, sizeof(DOUBLE));
  40. sub_ext(&e1, &e2);
  41. compact(&e1, &(p->fpart.d[0]), sizeof(DOUBLE));
  42. }