| 1 | 706 | jeremybenn | ------------------------------------------------------------------------------
 | 
      
         | 2 |  |  | --                                                                          --
 | 
      
         | 3 |  |  | --                         GNAT RUN-TIME COMPONENTS                         --
 | 
      
         | 4 |  |  | --                                                                          --
 | 
      
         | 5 |  |  | --                       S Y S T E M . I M G _ D E C                        --
 | 
      
         | 6 |  |  | --                                                                          --
 | 
      
         | 7 |  |  | --                                 S p e c                                  --
 | 
      
         | 8 |  |  | --                                                                          --
 | 
      
         | 9 |  |  | --          Copyright (C) 1992-2009, Free Software Foundation, Inc.         --
 | 
      
         | 10 |  |  | --                                                                          --
 | 
      
         | 11 |  |  | -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 | 
      
         | 12 |  |  | -- terms of the  GNU General Public License as published  by the Free Soft- --
 | 
      
         | 13 |  |  | -- ware  Foundation;  either version 3,  or (at your option) any later ver- --
 | 
      
         | 14 |  |  | -- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
 | 
      
         | 15 |  |  | -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
 | 
      
         | 16 |  |  | -- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
 | 
      
         | 17 |  |  | --                                                                          --
 | 
      
         | 18 |  |  | -- As a special exception under Section 7 of GPL version 3, you are granted --
 | 
      
         | 19 |  |  | -- additional permissions described in the GCC Runtime Library Exception,   --
 | 
      
         | 20 |  |  | -- version 3.1, as published by the Free Software Foundation.               --
 | 
      
         | 21 |  |  | --                                                                          --
 | 
      
         | 22 |  |  | -- You should have received a copy of the GNU General Public License and    --
 | 
      
         | 23 |  |  | -- a copy of the GCC Runtime Library Exception along with this program;     --
 | 
      
         | 24 |  |  | -- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
 | 
      
         | 25 |  |  | -- <http://www.gnu.org/licenses/>.                                          --
 | 
      
         | 26 |  |  | --                                                                          --
 | 
      
         | 27 |  |  | -- GNAT was originally developed  by the GNAT team at  New York University. --
 | 
      
         | 28 |  |  | -- Extensive contributions were provided by Ada Core Technologies Inc.      --
 | 
      
         | 29 |  |  | --                                                                          --
 | 
      
         | 30 |  |  | ------------------------------------------------------------------------------
 | 
      
         | 31 |  |  |  
 | 
      
         | 32 |  |  | --  Image for decimal fixed types where the size of the corresponding integer
 | 
      
         | 33 |  |  | --  type does not exceed Integer'Size (also used for Text_IO.Decimal_IO output)
 | 
      
         | 34 |  |  |  
 | 
      
         | 35 |  |  | package System.Img_Dec is
 | 
      
         | 36 |  |  |    pragma Pure;
 | 
      
         | 37 |  |  |  
 | 
      
         | 38 |  |  |    procedure Image_Decimal
 | 
      
         | 39 |  |  |      (V     : Integer;
 | 
      
         | 40 |  |  |       S     : in out String;
 | 
      
         | 41 |  |  |       P     : out Natural;
 | 
      
         | 42 |  |  |       Scale : Integer);
 | 
      
         | 43 |  |  |    --  Computes fixed_type'Image (V), where V is the integer value (in units of
 | 
      
         | 44 |  |  |    --  delta) of a decimal type whose Scale is as given and stores the result
 | 
      
         | 45 |  |  |    --  S (1 .. P), updating P to the value of L. The image is given by the
 | 
      
         | 46 |  |  |    --  rules in RM 3.5(34) for fixed-point type image functions. The caller
 | 
      
         | 47 |  |  |    --  guarantees that S is long enough to hold the result. S need not have a
 | 
      
         | 48 |  |  |    --  lower bound of 1.
 | 
      
         | 49 |  |  |  
 | 
      
         | 50 |  |  |    procedure Set_Image_Decimal
 | 
      
         | 51 |  |  |      (V     : Integer;
 | 
      
         | 52 |  |  |       S     : in out String;
 | 
      
         | 53 |  |  |       P     : in out Natural;
 | 
      
         | 54 |  |  |       Scale : Integer;
 | 
      
         | 55 |  |  |       Fore  : Natural;
 | 
      
         | 56 |  |  |       Aft   : Natural;
 | 
      
         | 57 |  |  |       Exp   : Natural);
 | 
      
         | 58 |  |  |    --  Sets the image of V, where V is the integer value (in units of delta)
 | 
      
         | 59 |  |  |    --  of a decimal type with the given Scale, starting at S (P + 1), updating
 | 
      
         | 60 |  |  |    --  P to point to the last character stored, the caller promises that the
 | 
      
         | 61 |  |  |    --  buffer is large enough and no check is made for this. Constraint_Error
 | 
      
         | 62 |  |  |    --  will not necessarily be raised if this requirement is violated, since
 | 
      
         | 63 |  |  |    --  it is perfectly valid to compile this unit with checks off. The Fore,
 | 
      
         | 64 |  |  |    --  Aft and Exp values can be set to any valid values for the case of use
 | 
      
         | 65 |  |  |    --  by Text_IO.Decimal_IO. Note that there is no leading space stored.
 | 
      
         | 66 |  |  |  
 | 
      
         | 67 |  |  |    procedure Set_Decimal_Digits
 | 
      
         | 68 |  |  |      (Digs  : in out String;
 | 
      
         | 69 |  |  |       NDigs : Natural;
 | 
      
         | 70 |  |  |       S     : out String;
 | 
      
         | 71 |  |  |       P     : in out Natural;
 | 
      
         | 72 |  |  |       Scale : Integer;
 | 
      
         | 73 |  |  |       Fore  : Natural;
 | 
      
         | 74 |  |  |       Aft   : Natural;
 | 
      
         | 75 |  |  |       Exp   : Natural);
 | 
      
         | 76 |  |  |    --  This procedure has the same semantics as Set_Image_Decimal, except that
 | 
      
         | 77 |  |  |    --  the value in Digs (1 .. NDigs) is given as a string of decimal digits
 | 
      
         | 78 |  |  |    --  preceded by either a minus sign or a space (i.e. the integer image of
 | 
      
         | 79 |  |  |    --  the value in units of delta). The call may destroy the value in Digs,
 | 
      
         | 80 |  |  |    --  which is why Digs is in-out (this happens if rounding is required).
 | 
      
         | 81 |  |  |    --  Set_Decimal_Digits is shared by all the decimal image routines.
 | 
      
         | 82 |  |  |  
 | 
      
         | 83 |  |  | end System.Img_Dec;
 |