home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / OutOfPhase1.01Source / OutOfPhase Folder / 64BitMath.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-01  |  2.5 KB  |  58 lines  |  [TEXT/KAHL]

  1. /* 64BitMath.c */
  2. /*****************************************************************************/
  3. /*                                                                           */
  4. /*    Out Of Phase:  Digital Music Synthesis on General Purpose Computers    */
  5. /*    Copyright (C) 1994  Thomas R. Lawrence                                 */
  6. /*                                                                           */
  7. /*    This program is free software; you can redistribute it and/or modify   */
  8. /*    it under the terms of the GNU General Public License as published by   */
  9. /*    the Free Software Foundation; either version 2 of the License, or      */
  10. /*    (at your option) any later version.                                    */
  11. /*                                                                           */
  12. /*    This program is distributed in the hope that it will be useful,        */
  13. /*    but WITHOUT ANY WARRANTY; without even the implied warranty of         */
  14. /*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
  15. /*    GNU General Public License for more details.                           */
  16. /*                                                                           */
  17. /*    You should have received a copy of the GNU General Public License      */
  18. /*    along with this program; if not, write to the Free Software            */
  19. /*    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.              */
  20. /*                                                                           */
  21. /*    Thomas R. Lawrence can be reached at tomlaw@world.std.com.             */
  22. /*                                                                           */
  23. /*****************************************************************************/
  24.  
  25. #include "MiscInfo.h"
  26. #include "Audit.h"
  27. #include "Debug.h"
  28. #include "Definitions.h"
  29.  
  30. #include "64BitMath.h"
  31.  
  32.  
  33. #ifdef ENABLEGENERICLONGLONG
  34. /* add two longlongs:  *L = *L + *R */
  35. void                            LongLongAdd(LongLongRec* L, LongLongRec* R)
  36.     {
  37.         double                    Overflow;
  38.         double                    LowTemp;
  39.  
  40.         ERROR(sizeof(long) == 8,PRERR(AllowResume,
  41.             "LongLongAdd:  64-bit longs are available on this system"));
  42.  
  43.         /* low order stuff */
  44.         LowTemp = (double)((L->Low32Bits + R->Low32Bits) & 0xffffffff);
  45.  
  46.         /* check for overflow */
  47.         Overflow = 0;
  48.         if (LowTemp < (double)L->Low32Bits + (double)R->Low32Bits)
  49.             {
  50.                 Overflow = 1;
  51.             }
  52.  
  53.         /* high order stuff */
  54.         L->Low32Bits = LowTemp;
  55.         L->High32Bits = L->High32Bits + R->High32Bits + Overflow;
  56.     }
  57. #endif
  58.