flt_ar2flt.c 689 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #include "flt_misc.h"
  7. #include <em_arith.h>
  8. void
  9. flt_arith2flt(n, e, uns)
  10. register arith n;
  11. register flt_arith *e;
  12. {
  13. /* Convert the arith "n" to a flt_arith "e".
  14. */
  15. if (!uns && n < 0) {
  16. e->flt_sign = 1;
  17. n = -n;
  18. }
  19. else e->flt_sign = 0;
  20. if (sizeof(arith) == 4) {
  21. e->m1 = 0; e->m2 = n;
  22. }
  23. else {
  24. e->m2 = n & 0xffffffffL;
  25. n >>= 1;
  26. n &= ~((arith) 1 << (8*sizeof(arith)-1));
  27. e->m1 = (n >> 31);
  28. }
  29. if (n == 0) {
  30. e->flt_exp = 0;
  31. return;
  32. }
  33. e->flt_exp = 63;
  34. flt_status = 0;
  35. flt_nrm(e);
  36. }