home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / LIBSRC.ZOO / libsrc / longlong / negdi2.c < prev    next >
C/C++ Source or Header  |  1992-02-22  |  588b  |  44 lines

  1. #include "longlong.h"
  2.  
  3. static int bneg ();
  4.  
  5. long long 
  6. __negdi2 (u)
  7.      long long u;
  8. {
  9.   unsigned long a[2], b[2];
  10.   long_long w;
  11.   long_long uu;
  12.  
  13.   uu.ll = u;
  14.  
  15.   a[HIGH] = uu.s.high;
  16.   a[LOW] = uu.s.low;
  17.  
  18.   bneg (a, b, sizeof b);
  19.  
  20.   w.s.high = b[HIGH];
  21.   w.s.low = b[LOW];
  22.   return w.ll;
  23. }
  24.  
  25. static int
  26. bneg (a, b, n)
  27.      unsigned short *a, *b;
  28.      size_t n;
  29. {
  30.   signed long acc;
  31.   int i;
  32.  
  33.   n /= sizeof (short);
  34.  
  35.   acc = 0;
  36.   for (i = little_end (n); is_not_msd (i, n); i = next_msd (i))
  37.     {
  38.       acc -= a[i];
  39.       b[i] = acc & low16;
  40.       acc = acc >> 16;
  41.     }
  42.   return acc;
  43. }
  44.