flt_nrm.c 668 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. /*
  2. (c) copyright 1989 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. #include "flt_misc.h"
  7. void
  8. flt_nrm(e)
  9. register flt_arith *e;
  10. {
  11. if ((e->m1 | e->m2) == 0L) {
  12. e->flt_exp = 0;
  13. e->flt_sign = 0;
  14. return;
  15. }
  16. /* if top word is zero mov low word */
  17. /* to top word, adjust exponent value */
  18. if (e->m1 == 0L) {
  19. e->m1 = e->m2;
  20. e->m2 = 0L;
  21. e->flt_exp -= 32;
  22. }
  23. if ((e->m1 & 0x80000000) == 0) {
  24. long l = 0x40000000;
  25. int cnt = -1;
  26. while (! (l & e->m1)) {
  27. l >>= 1;
  28. cnt--;
  29. }
  30. e->flt_exp += cnt;
  31. flt_b64_sft(&(e->flt_mantissa), cnt);
  32. }
  33. }