OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-dev/] [fsf-gcc-snapshot-1-mar-12/] [or1k-gcc/] [gcc/] [ada/] [s-diflio.ads] - Blame information for rev 847

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 706 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT RUN-TIME COMPONENTS                         --
4
--                                                                          --
5
--                    S Y S T E M . D I M . F L O A T _ I O                 --
6
--                                                                          --
7
--                                 S p e c                                  --
8
--                                                                          --
9
--          Copyright (C) 2011-2012, 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
--  This package provides output routines for float dimensioned types. All Put
33
--  routines are modelled after those in package Ada.Text_IO.Float_IO with the
34
--  addition of an extra default parameter.
35
 
36
--  Parameter Symbol may be used in the following manner (all the examples are
37
--  based on the MKS system of units as defined in package System.Dim.Mks):
38
 
39
--  Case 1. A value is supplied for Symbol
40
 
41
--    The string appears as a suffix of Item
42
 
43
--      Obj : Mks_Type := 2.6;
44
--      Put (Obj, 1, 1, 0, " dimensionless");
45
 
46
--      The corresponding output is: 2.6 dimensionless
47
 
48
--  Case 2. No value is supplied for Symbol and Item is dimensionless
49
 
50
--    Item appears without a suffix
51
 
52
--      Obj : Mks_Type := 2.6;
53
--      Put (Obj, 1, 1, 0);
54
 
55
--      The corresponding output is: 2.6
56
 
57
--  Case 3. No value is supplied for Symbol and Item has a dimension
58
 
59
--    If the type of Item is a dimensioned subtype whose symbolic name is not
60
--    empty, then the symbolic name appears as a suffix.
61
 
62
--      subtype Length is Mks_Type
63
--        with
64
--         Dimension => ('m',
65
--           Meter =>  1,
66
--           others => 0);
67
 
68
--      Obj : Length := 2.3 * dm;
69
--      Put (Obj, 1, 2, 0);
70
 
71
--      The corresponding output is: 0.23 m
72
 
73
--    Otherwise, a new string is created and appears as a suffix of Item.
74
--    This string results in the successive concatanations between each
75
--    dimension symbolic name raised by its corresponding dimension power from
76
--    the dimensions of Item.
77
 
78
--      subtype Random is Mks_Type
79
--        with
80
--         Dimension => ("",
81
--         Meter =>   3,
82
--         Candela => -1,
83
--         others =>  0);
84
 
85
--      Obj : Random := 5.0;
86
--      Put (Obj);
87
 
88
--      The corresponding output is: 5.0 m**3.cd**(-1)
89
 
90
--      Put (3.3 * km * dm * min, 5, 1, 0);
91
 
92
--      The corresponding output is: 19800.0 m**2.s
93
 
94
with Ada.Text_IO; use Ada.Text_IO;
95
 
96
generic
97
   type Num_Dim_Float is digits <>;
98
 
99
package System.Dim.Float_IO is
100
 
101
   Default_Fore : Field := 2;
102
   Default_Aft  : Field := Num_Dim_Float'Digits - 1;
103
   Default_Exp  : Field := 3;
104
 
105
   procedure Put
106
     (File    : File_Type;
107
      Item    : Num_Dim_Float;
108
      Fore    : Field  := Default_Fore;
109
      Aft     : Field  := Default_Aft;
110
      Exp     : Field  := Default_Exp;
111
      Symbols : String := "");
112
 
113
   procedure Put
114
     (Item    : Num_Dim_Float;
115
      Fore    : Field  := Default_Fore;
116
      Aft     : Field  := Default_Aft;
117
      Exp     : Field  := Default_Exp;
118
      Symbols : String := "");
119
 
120
   procedure Put
121
     (To      : out String;
122
      Item    : Num_Dim_Float;
123
      Aft     : Field  := Default_Aft;
124
      Exp     : Field  := Default_Exp;
125
      Symbols : String := "");
126
 
127
   pragma Inline (Put);
128
 
129
end System.Dim.Float_IO;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.