1 ------------------------------------------------------------------------------
3 -- GNAT RUN-TIME COMPONENTS --
5 -- A D A . T E X T _ I O . D E C I M A L _ I O --
9 -- Copyright (C) 1992-2017, 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 with Ada
.Text_IO
.Decimal_Aux
;
34 package body Ada
.Text_IO
.Decimal_IO
is
36 package Aux
renames Ada
.Text_IO
.Decimal_Aux
;
38 Scale
: constant Integer := Num
'Scale;
49 pragma Unsuppress
(Range_Check
);
52 if Num
'Size > Integer'Size then
53 Item
:= Num
'Fixed_Value (Aux
.Get_LLD
(File
, Width
, Scale
));
55 Item
:= Num
'Fixed_Value (Aux
.Get_Dec
(File
, Width
, Scale
));
59 when Constraint_Error
=> raise Data_Error
;
67 Get
(Current_In
, Item
, Width
);
75 pragma Unsuppress
(Range_Check
);
78 if Num
'Size > Integer'Size then
79 Item
:= Num
'Fixed_Value
80 (Aux
.Gets_LLD
(From
, Last
'Unrestricted_Access, Scale
));
82 Item
:= Num
'Fixed_Value
83 (Aux
.Gets_Dec
(From
, Last
'Unrestricted_Access, Scale
));
87 when Constraint_Error
=> raise Data_Error
;
97 Fore
: Field
:= Default_Fore
;
98 Aft
: Field
:= Default_Aft
;
99 Exp
: Field
:= Default_Exp
)
102 if Num
'Size > Integer'Size then
104 (File
, Long_Long_Integer'Integer_Value (Item
),
105 Fore
, Aft
, Exp
, Scale
);
108 (File
, Integer'Integer_Value (Item
), Fore
, Aft
, Exp
, Scale
);
114 Fore
: Field
:= Default_Fore
;
115 Aft
: Field
:= Default_Aft
;
116 Exp
: Field
:= Default_Exp
)
119 Put
(Current_Out
, Item
, Fore
, Aft
, Exp
);
125 Aft
: Field
:= Default_Aft
;
126 Exp
: Field
:= Default_Exp
)
129 if Num
'Size > Integer'Size then
131 (To
, Long_Long_Integer'Integer_Value (Item
), Aft
, Exp
, Scale
);
133 Aux
.Puts_Dec
(To
, Integer'Integer_Value (Item
), Aft
, Exp
, Scale
);
137 end Ada
.Text_IO
.Decimal_IO
;