1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- S Y S T E M . D I M . F L O A T _ I O --
9 -- Copyright (C) 2011-2012, Free Software Foundation, Inc. --
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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
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.
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):
39 -- Case 1. A value is supplied for Symbol
41 -- The string appears as a suffix of Item
43 -- Obj : Mks_Type := 2.6;
44 -- Put (Obj, 1, 1, 0, " dimensionless");
46 -- The corresponding output is: 2.6 dimensionless
48 -- Case 2. No value is supplied for Symbol and Item is dimensionless
50 -- Item appears without a suffix
52 -- Obj : Mks_Type := 2.6;
53 -- Put (Obj, 1, 1, 0);
55 -- The corresponding output is: 2.6
57 -- Case 3. No value is supplied for Symbol and Item has a dimension
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.
62 -- subtype Length is Mks_Type
68 -- Obj : Length := 2.3 * dm;
69 -- Put (Obj, 1, 2, 0);
71 -- The corresponding output is: 0.23 m
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.
78 -- subtype Random is Mks_Type
85 -- Obj : Random := 5.0;
88 -- The corresponding output is: 5.0 m**3.cd**(-1)
90 -- Put (3.3 * km * dm * min, 5, 1, 0);
92 -- The corresponding output is: 19800.0 m**2.s
94 with Ada
.Text_IO
; use Ada
.Text_IO
;
97 type Num_Dim_Float
is digits <>;
99 package System
.Dim
.Float_IO
is
101 Default_Fore
: Field
:= 2;
102 Default_Aft
: Field
:= Num_Dim_Float
'Digits - 1;
103 Default_Exp
: Field
:= 3;
107 Item
: Num_Dim_Float
;
108 Fore
: Field
:= Default_Fore
;
109 Aft
: Field
:= Default_Aft
;
110 Exp
: Field
:= Default_Exp
;
111 Symbols
: String := "");
114 (Item
: Num_Dim_Float
;
115 Fore
: Field
:= Default_Fore
;
116 Aft
: Field
:= Default_Aft
;
117 Exp
: Field
:= Default_Exp
;
118 Symbols
: String := "");
122 Item
: Num_Dim_Float
;
123 Aft
: Field
:= Default_Aft
;
124 Exp
: Field
:= Default_Exp
;
125 Symbols
: String := "");
129 end System
.Dim
.Float_IO
;