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-2006, 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 2, 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 with Ada
.Text_IO
.Decimal_Aux
;
36 package body Ada
.Text_IO
.Decimal_IO
is
38 package Aux
renames Ada
.Text_IO
.Decimal_Aux
;
40 Scale
: constant Integer := Num
'Scale;
51 pragma Unsuppress
(Range_Check
);
54 if Num
'Size > Integer'Size then
55 Item
:= Num
'Fixed_Value (Aux
.Get_LLD
(File
, Width
, Scale
));
58 Item
:= Num
'Fixed_Value (Aux
.Get_Dec
(File
, Width
, Scale
));
62 when Constraint_Error
=> raise Data_Error
;
70 Get
(Current_In
, Item
, Width
);
78 pragma Unsuppress
(Range_Check
);
81 if Num
'Size > Integer'Size then
82 Item
:= Num
'Fixed_Value
83 (Aux
.Gets_LLD
(From
, Last
'Unrestricted_Access, Scale
));
85 Item
:= Num
'Fixed_Value
86 (Aux
.Gets_Dec
(From
, Last
'Unrestricted_Access, Scale
));
90 when Constraint_Error
=> raise Data_Error
;
100 Fore
: Field
:= Default_Fore
;
101 Aft
: Field
:= Default_Aft
;
102 Exp
: Field
:= Default_Exp
)
105 if Num
'Size > Integer'Size then
107 (File
, Long_Long_Integer'Integer_Value (Item
),
108 Fore
, Aft
, Exp
, Scale
);
111 (File
, Integer'Integer_Value (Item
), Fore
, Aft
, Exp
, Scale
);
117 Fore
: Field
:= Default_Fore
;
118 Aft
: Field
:= Default_Aft
;
119 Exp
: Field
:= Default_Exp
)
122 Put
(Current_Out
, Item
, Fore
, Aft
, Exp
);
128 Aft
: Field
:= Default_Aft
;
129 Exp
: Field
:= Default_Exp
)
132 if Num
'Size > Integer'Size then
134 (To
, Long_Long_Integer'Integer_Value (Item
), Aft
, Exp
, Scale
);
136 Aux
.Puts_Dec
(To
, Integer'Integer_Value (Item
), Aft
, Exp
, Scale
);
140 end Ada
.Text_IO
.Decimal_IO
;