cmf4.c 735 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. COMPARE SINGLES (CMF 4)
  8. */
  9. #include "FP_types.h"
  10. #include "get_put.h"
  11. int
  12. cmf4(f1,f2)
  13. SINGLE f1,f2;
  14. {
  15. /*
  16. * return ((f1 < f2) ? 1 : (f1 - f2))
  17. */
  18. #define SIGN(x) (((x) < 0) ? -1 : 1)
  19. int sign1,sign2;
  20. long l1,l2;
  21. l1 = get4((char *) &f1);
  22. l2 = get4((char *) &f2);
  23. if (l1 == l2) return 0;
  24. sign1 = SIGN(l1);
  25. sign2 = SIGN(l2);
  26. if (sign1 != sign2) {
  27. if ((l1 & 0x7fffffff) == 0 &&
  28. (l2 & 0x7fffffff) == 0) return 0;
  29. return ((sign1 > 0) ? -1 : 1);
  30. }
  31. return (sign1 * ((l1 < l2) ? 1 : -1));
  32. }