flt_ar2flt.c 667 B

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