home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gnat-2.06-src.tgz / tar.out / fsf / gnat / ada / s-arit64.ads < prev    next >
Text File  |  1996-09-28  |  4KB  |  77 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                         GNAT COMPILER COMPONENTS                         --
  4. --                                                                          --
  5. --                      S Y S T E M . A R I T H _ 6 4                       --
  6. --                                                                          --
  7. --                                 S p e c                                  --
  8. --                                                                          --
  9. --                            $Revision: 1.2 $                              --
  10. --                                                                          --
  11. -- The GNAT library is free software; you can redistribute it and/or modify --
  12. -- it under terms of the GNU Library General Public License as published by --
  13. -- the Free Software  Foundation; either version 2, or (at your option) any --
  14. -- later version.  The GNAT library is distributed in the hope that it will --
  15. -- be useful, but WITHOUT ANY WARRANTY;  without even  the implied warranty --
  16. -- of MERCHANTABILITY  or  FITNESS FOR  A PARTICULAR PURPOSE.  See the  GNU --
  17. -- Library  General  Public  License for  more  details.  You  should  have --
  18. -- received  a copy of the GNU  Library  General Public License  along with --
  19. -- the GNAT library;  see the file  COPYING.LIB.  If not, write to the Free --
  20. -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.        --
  21. --                                                                          --
  22. ------------------------------------------------------------------------------
  23.  
  24. --  This unit provides software routines for doing arithmetic on 64-bit
  25. --  signed integer values in cases where either overflow checking is
  26. --  required, or intermediate results are longer than 64 bits.
  27.  
  28.  
  29. with Interfaces;
  30.  
  31. package System.Arith_64 is
  32.  
  33.    subtype Int64 is Interfaces.Integer_64;
  34.  
  35.    function Add_With_Ovflo_Check (X, Y : Int64) return Int64;
  36.    --  Raises Constraint_Error if sum of operands overflows 64 bits,
  37.    --  otherwise returns the 64-bit signed integer sum.
  38.  
  39.    function Subtract_With_Ovflo_Check (X, Y : Int64) return Int64;
  40.    --  Raises Constraint_Error if difference of operands overflows 64
  41.    --  bits, otherwise returns the 64-bit signed integer difference.
  42.  
  43.    function Multiply_With_Ovflo_Check (X, Y : Int64) return Int64;
  44.    --  Raises Constraint_Error if product of operands overflows 64
  45.    --  bits, otherwise returns the 64-bit signed integer difference.
  46.  
  47.    function Divide_With_Ovflo_Check (X, Y : Int64) return Int64;
  48.    --  Raises Constraint_Error if quotient of operands overflows 64
  49.    --  bits, otherwise returns the 64-bit signed integer difference.
  50.    --  The overflow cases are when Y is zero, or X is the largest
  51.    --  negative integer, and Y is minus one.
  52.  
  53.    procedure Scaled_Divide
  54.      (X, Y, Z : Int64;
  55.       Q, R    : out Int64;
  56.       Round   : Boolean);
  57.    --  Performs the division of (X * Y) / Z, storing the quotient in Q
  58.    --  and the remainder in R. Constraint_Error is raised if Z is zero,
  59.    --  or if the quotient does not fit in 64-bits. Round indicates if
  60.    --  the result should be rounded. If Round is False, then Q, R are
  61.    --  the normal quotient and remainder from a truncating division.
  62.    --  If Round is True, then Q is the rounded quotient. the remainder
  63.    --  R is not affected by the setting of the Round flag.
  64.  
  65.    procedure Double_Divide
  66.      (X, Y, Z : Int64;
  67.       Q, R    : out Int64;
  68.       Round   : Boolean);
  69.    --  Performs the division X / (Y * Z), storing the quotient in Q and
  70.    --  the remainder in R. Constraint_Error is raised if Y or Z is zero.
  71.    --  Round indicates if the result should be rounded. If Round is False,
  72.    --  then Q, R are the normal quotient and remainder from a truncating
  73.    --  division. If Round is True, then Q is the rounded quotient. The
  74.    --  remainder R is not affected by the setting of the Round flag.
  75.  
  76. end System.Arith_64;
  77.