nrm_ext.c 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. /*
  8. NORMALIZE an EXTENDED FORMAT NUMBER
  9. */
  10. /********************************************************/
  11. #include "FP_shift.h"
  12. #include "FP_types.h"
  13. void
  14. nrm_ext(e1)
  15. EXTEND *e1;
  16. {
  17. /* we assume that the mantissa != 0 */
  18. /* if it is then just return */
  19. /* to let it be a problem elsewhere */
  20. /* THAT IS, The exponent is not set to */
  21. /* zero. If we don't test here an */
  22. /* infinite loop is generated when */
  23. /* mantissa is zero */
  24. if ((e1->m1 | e1->m2) == 0L)
  25. return;
  26. /* if top word is zero mov low word */
  27. /* to top word, adjust exponent value */
  28. if (e1->m1 == 0L) {
  29. e1->m1 = e1->m2;
  30. e1->m2 = 0L;
  31. e1->exp -= 32;
  32. }
  33. if ((e1->m1 & NORMBIT) == 0) {
  34. unsigned long l = ((unsigned long)NORMBIT >> 1);
  35. int cnt = -1;
  36. while (! (l & e1->m1)) {
  37. l >>= 1;
  38. cnt--;
  39. }
  40. e1->exp += cnt;
  41. b64_sft(&(e1->mantissa), cnt);
  42. }
  43. }