b64_add.c 749 B

123456789101112131415161718192021222324252627282930
  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. int
  8. flt_b64_add(e1,e2)
  9. register struct flt_mantissa *e1,*e2;
  10. {
  11. int overflow;
  12. int carry;
  13. /* add higher pair of 32 bits */
  14. overflow = ucmp((long)0xFFFFFFFF - e1->flt_h_32, e2->flt_h_32) < 0;
  15. e1->flt_h_32 += e2->flt_h_32;
  16. /* add lower pair of 32 bits */
  17. carry = ucmp((long)0xFFFFFFFF - e1->flt_l_32, e2->flt_l_32) < 0;
  18. e1->flt_l_32 += e2->flt_l_32;
  19. if ((carry) && ((++e1->flt_h_32 &~0xFFFFFFFF) || e1->flt_h_32 == 0)) {
  20. e1->flt_h_32 = 0;
  21. return(1); /* had a 64 bit overflow */
  22. }
  23. return(overflow); /* return status from higher add */
  24. }