annotate gcc/ada/libgnat/s-imgdec.adb @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 84e7813d76e9
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT RUN-TIME COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- S Y S T E M . I M G _ D E C --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- B o d y --
kono
parents:
diff changeset
8 -- --
145
1830386684a0 gcc-9.2.0
anatofuz
parents: 131
diff changeset
9 -- Copyright (C) 1992-2019, Free Software Foundation, Inc. --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 with System.Img_Int; use System.Img_Int;
kono
parents:
diff changeset
33
kono
parents:
diff changeset
34 package body System.Img_Dec is
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 -------------------
kono
parents:
diff changeset
37 -- Image_Decimal --
kono
parents:
diff changeset
38 -------------------
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 procedure Image_Decimal
kono
parents:
diff changeset
41 (V : Integer;
kono
parents:
diff changeset
42 S : in out String;
kono
parents:
diff changeset
43 P : out Natural;
kono
parents:
diff changeset
44 Scale : Integer)
kono
parents:
diff changeset
45 is
kono
parents:
diff changeset
46 pragma Assert (S'First = 1);
kono
parents:
diff changeset
47
kono
parents:
diff changeset
48 begin
kono
parents:
diff changeset
49 -- Add space at start for non-negative numbers
kono
parents:
diff changeset
50
kono
parents:
diff changeset
51 if V >= 0 then
kono
parents:
diff changeset
52 S (1) := ' ';
kono
parents:
diff changeset
53 P := 1;
kono
parents:
diff changeset
54 else
kono
parents:
diff changeset
55 P := 0;
kono
parents:
diff changeset
56 end if;
kono
parents:
diff changeset
57
kono
parents:
diff changeset
58 Set_Image_Decimal (V, S, P, Scale, 1, Integer'Max (1, Scale), 0);
kono
parents:
diff changeset
59 end Image_Decimal;
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 ------------------------
kono
parents:
diff changeset
62 -- Set_Decimal_Digits --
kono
parents:
diff changeset
63 ------------------------
kono
parents:
diff changeset
64
kono
parents:
diff changeset
65 procedure Set_Decimal_Digits
kono
parents:
diff changeset
66 (Digs : in out String;
kono
parents:
diff changeset
67 NDigs : Natural;
kono
parents:
diff changeset
68 S : out String;
kono
parents:
diff changeset
69 P : in out Natural;
kono
parents:
diff changeset
70 Scale : Integer;
kono
parents:
diff changeset
71 Fore : Natural;
kono
parents:
diff changeset
72 Aft : Natural;
kono
parents:
diff changeset
73 Exp : Natural)
kono
parents:
diff changeset
74 is
kono
parents:
diff changeset
75 Minus : constant Boolean := (Digs (Digs'First) = '-');
kono
parents:
diff changeset
76 -- Set True if input is negative
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 Zero : Boolean := (Digs (Digs'First + 1) = '0');
kono
parents:
diff changeset
79 -- Set True if input is exactly zero (only case when a leading zero
kono
parents:
diff changeset
80 -- is permitted in the input string given to this procedure). This
kono
parents:
diff changeset
81 -- flag can get set later if rounding causes the value to become zero.
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 FD : Natural := 2;
kono
parents:
diff changeset
84 -- First digit position of digits remaining to be processed
kono
parents:
diff changeset
85
kono
parents:
diff changeset
86 LD : Natural := NDigs;
kono
parents:
diff changeset
87 -- Last digit position of digits remaining to be processed
kono
parents:
diff changeset
88
kono
parents:
diff changeset
89 ND : Natural := NDigs - 1;
kono
parents:
diff changeset
90 -- Number of digits remaining to be processed (LD - FD + 1)
kono
parents:
diff changeset
91
kono
parents:
diff changeset
92 Digits_Before_Point : Integer := ND - Scale;
kono
parents:
diff changeset
93 -- Number of digits before decimal point in the input value. This
kono
parents:
diff changeset
94 -- value can be negative if the input value is less than 0.1, so
kono
parents:
diff changeset
95 -- it is an indication of the current exponent. Digits_Before_Point
kono
parents:
diff changeset
96 -- is adjusted if the rounding step generates an extra digit.
kono
parents:
diff changeset
97
kono
parents:
diff changeset
98 Digits_After_Point : constant Natural := Integer'Max (1, Aft);
kono
parents:
diff changeset
99 -- Digit positions after decimal point in result string
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 Expon : Integer;
kono
parents:
diff changeset
102 -- Integer value of exponent
kono
parents:
diff changeset
103
kono
parents:
diff changeset
104 procedure Round (N : Integer);
kono
parents:
diff changeset
105 -- Round the number in Digs. N is the position of the last digit to be
kono
parents:
diff changeset
106 -- retained in the rounded position (rounding is based on Digs (N + 1)
kono
parents:
diff changeset
107 -- FD, LD, ND are reset as necessary if required. Note that if the
kono
parents:
diff changeset
108 -- result value rounds up (e.g. 9.99 => 10.0), an extra digit can be
kono
parents:
diff changeset
109 -- placed in the sign position as a result of the rounding, this is
kono
parents:
diff changeset
110 -- the case in which FD is adjusted. The call to Round has no effect
kono
parents:
diff changeset
111 -- if N is outside the range FD .. LD.
kono
parents:
diff changeset
112
kono
parents:
diff changeset
113 procedure Set (C : Character);
kono
parents:
diff changeset
114 pragma Inline (Set);
kono
parents:
diff changeset
115 -- Sets character C in output buffer
kono
parents:
diff changeset
116
kono
parents:
diff changeset
117 procedure Set_Blanks_And_Sign (N : Integer);
kono
parents:
diff changeset
118 -- Sets leading blanks and minus sign if needed. N is the number of
kono
parents:
diff changeset
119 -- positions to be filled (a minus sign is output even if N is zero
kono
parents:
diff changeset
120 -- or negative, For a positive value, if N is non-positive, then
kono
parents:
diff changeset
121 -- a leading blank is filled.
kono
parents:
diff changeset
122
kono
parents:
diff changeset
123 procedure Set_Digits (S, E : Natural);
kono
parents:
diff changeset
124 pragma Inline (Set_Digits);
kono
parents:
diff changeset
125 -- Set digits S through E from Digs, no effect if S > E
kono
parents:
diff changeset
126
kono
parents:
diff changeset
127 procedure Set_Zeroes (N : Integer);
kono
parents:
diff changeset
128 pragma Inline (Set_Zeroes);
kono
parents:
diff changeset
129 -- Set N zeroes, no effect if N is negative
kono
parents:
diff changeset
130
kono
parents:
diff changeset
131 -----------
kono
parents:
diff changeset
132 -- Round --
kono
parents:
diff changeset
133 -----------
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 procedure Round (N : Integer) is
kono
parents:
diff changeset
136 D : Character;
kono
parents:
diff changeset
137
kono
parents:
diff changeset
138 begin
kono
parents:
diff changeset
139 -- Nothing to do if rounding past the last digit we have
kono
parents:
diff changeset
140
kono
parents:
diff changeset
141 if N >= LD then
kono
parents:
diff changeset
142 return;
kono
parents:
diff changeset
143
kono
parents:
diff changeset
144 -- Cases of rounding before the initial digit
kono
parents:
diff changeset
145
kono
parents:
diff changeset
146 elsif N < FD then
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 -- The result is zero, unless we are rounding just before
kono
parents:
diff changeset
149 -- the first digit, and the first digit is five or more.
kono
parents:
diff changeset
150
kono
parents:
diff changeset
151 if N = 1 and then Digs (Digs'First + 1) >= '5' then
kono
parents:
diff changeset
152 Digs (Digs'First) := '1';
kono
parents:
diff changeset
153 else
kono
parents:
diff changeset
154 Digs (Digs'First) := '0';
kono
parents:
diff changeset
155 Zero := True;
kono
parents:
diff changeset
156 end if;
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 Digits_Before_Point := Digits_Before_Point + 1;
kono
parents:
diff changeset
159 FD := 1;
kono
parents:
diff changeset
160 LD := 1;
kono
parents:
diff changeset
161 ND := 1;
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 -- Normal case of rounding an existing digit
kono
parents:
diff changeset
164
kono
parents:
diff changeset
165 else
kono
parents:
diff changeset
166 LD := N;
kono
parents:
diff changeset
167 ND := LD - 1;
kono
parents:
diff changeset
168
kono
parents:
diff changeset
169 if Digs (N + 1) >= '5' then
kono
parents:
diff changeset
170 for J in reverse 2 .. N loop
kono
parents:
diff changeset
171 D := Character'Succ (Digs (J));
kono
parents:
diff changeset
172
kono
parents:
diff changeset
173 if D <= '9' then
kono
parents:
diff changeset
174 Digs (J) := D;
kono
parents:
diff changeset
175 return;
kono
parents:
diff changeset
176 else
kono
parents:
diff changeset
177 Digs (J) := '0';
kono
parents:
diff changeset
178 end if;
kono
parents:
diff changeset
179 end loop;
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 -- Here the rounding overflows into the sign position. That's
kono
parents:
diff changeset
182 -- OK, because we already captured the value of the sign and
kono
parents:
diff changeset
183 -- we are in any case destroying the value in the Digs buffer
kono
parents:
diff changeset
184
kono
parents:
diff changeset
185 Digs (Digs'First) := '1';
kono
parents:
diff changeset
186 FD := 1;
kono
parents:
diff changeset
187 ND := ND + 1;
kono
parents:
diff changeset
188 Digits_Before_Point := Digits_Before_Point + 1;
kono
parents:
diff changeset
189 end if;
kono
parents:
diff changeset
190 end if;
kono
parents:
diff changeset
191 end Round;
kono
parents:
diff changeset
192
kono
parents:
diff changeset
193 ---------
kono
parents:
diff changeset
194 -- Set --
kono
parents:
diff changeset
195 ---------
kono
parents:
diff changeset
196
kono
parents:
diff changeset
197 procedure Set (C : Character) is
kono
parents:
diff changeset
198 begin
kono
parents:
diff changeset
199 P := P + 1;
kono
parents:
diff changeset
200 S (P) := C;
kono
parents:
diff changeset
201 end Set;
kono
parents:
diff changeset
202
kono
parents:
diff changeset
203 -------------------------
kono
parents:
diff changeset
204 -- Set_Blanks_And_Sign --
kono
parents:
diff changeset
205 -------------------------
kono
parents:
diff changeset
206
kono
parents:
diff changeset
207 procedure Set_Blanks_And_Sign (N : Integer) is
kono
parents:
diff changeset
208 W : Integer := N;
kono
parents:
diff changeset
209
kono
parents:
diff changeset
210 begin
kono
parents:
diff changeset
211 if Minus then
kono
parents:
diff changeset
212 W := W - 1;
kono
parents:
diff changeset
213
kono
parents:
diff changeset
214 for J in 1 .. W loop
kono
parents:
diff changeset
215 Set (' ');
kono
parents:
diff changeset
216 end loop;
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 Set ('-');
kono
parents:
diff changeset
219
kono
parents:
diff changeset
220 else
kono
parents:
diff changeset
221 for J in 1 .. W loop
kono
parents:
diff changeset
222 Set (' ');
kono
parents:
diff changeset
223 end loop;
kono
parents:
diff changeset
224 end if;
kono
parents:
diff changeset
225 end Set_Blanks_And_Sign;
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 ----------------
kono
parents:
diff changeset
228 -- Set_Digits --
kono
parents:
diff changeset
229 ----------------
kono
parents:
diff changeset
230
kono
parents:
diff changeset
231 procedure Set_Digits (S, E : Natural) is
kono
parents:
diff changeset
232 begin
kono
parents:
diff changeset
233 for J in S .. E loop
kono
parents:
diff changeset
234 Set (Digs (J));
kono
parents:
diff changeset
235 end loop;
kono
parents:
diff changeset
236 end Set_Digits;
kono
parents:
diff changeset
237
kono
parents:
diff changeset
238 ----------------
kono
parents:
diff changeset
239 -- Set_Zeroes --
kono
parents:
diff changeset
240 ----------------
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 procedure Set_Zeroes (N : Integer) is
kono
parents:
diff changeset
243 begin
kono
parents:
diff changeset
244 for J in 1 .. N loop
kono
parents:
diff changeset
245 Set ('0');
kono
parents:
diff changeset
246 end loop;
kono
parents:
diff changeset
247 end Set_Zeroes;
kono
parents:
diff changeset
248
kono
parents:
diff changeset
249 -- Start of processing for Set_Decimal_Digits
kono
parents:
diff changeset
250
kono
parents:
diff changeset
251 begin
kono
parents:
diff changeset
252 -- Case of exponent given
kono
parents:
diff changeset
253
kono
parents:
diff changeset
254 if Exp > 0 then
kono
parents:
diff changeset
255 Set_Blanks_And_Sign (Fore - 1);
kono
parents:
diff changeset
256 Round (Digits_After_Point + 2);
kono
parents:
diff changeset
257 Set (Digs (FD));
kono
parents:
diff changeset
258 FD := FD + 1;
kono
parents:
diff changeset
259 ND := ND - 1;
kono
parents:
diff changeset
260 Set ('.');
kono
parents:
diff changeset
261
kono
parents:
diff changeset
262 if ND >= Digits_After_Point then
kono
parents:
diff changeset
263 Set_Digits (FD, FD + Digits_After_Point - 1);
kono
parents:
diff changeset
264 else
kono
parents:
diff changeset
265 Set_Digits (FD, LD);
kono
parents:
diff changeset
266 Set_Zeroes (Digits_After_Point - ND);
kono
parents:
diff changeset
267 end if;
kono
parents:
diff changeset
268
kono
parents:
diff changeset
269 -- Calculate exponent. The number of digits before the decimal point
kono
parents:
diff changeset
270 -- in the input is Digits_Before_Point, and the number of digits
kono
parents:
diff changeset
271 -- before the decimal point in the output is 1, so we can get the
kono
parents:
diff changeset
272 -- exponent as the difference between these two values. The one
kono
parents:
diff changeset
273 -- exception is for the value zero, which by convention has an
kono
parents:
diff changeset
274 -- exponent of +0.
kono
parents:
diff changeset
275
kono
parents:
diff changeset
276 Expon := (if Zero then 0 else Digits_Before_Point - 1);
kono
parents:
diff changeset
277 Set ('E');
kono
parents:
diff changeset
278 ND := 0;
kono
parents:
diff changeset
279
kono
parents:
diff changeset
280 if Expon >= 0 then
kono
parents:
diff changeset
281 Set ('+');
kono
parents:
diff changeset
282 Set_Image_Integer (Expon, Digs, ND);
kono
parents:
diff changeset
283 else
kono
parents:
diff changeset
284 Set ('-');
kono
parents:
diff changeset
285 Set_Image_Integer (-Expon, Digs, ND);
kono
parents:
diff changeset
286 end if;
kono
parents:
diff changeset
287
kono
parents:
diff changeset
288 Set_Zeroes (Exp - ND - 1);
kono
parents:
diff changeset
289 Set_Digits (1, ND);
kono
parents:
diff changeset
290 return;
kono
parents:
diff changeset
291
kono
parents:
diff changeset
292 -- Case of no exponent given. To make these cases clear, we use
kono
parents:
diff changeset
293 -- examples. For all the examples, we assume Fore = 2, Aft = 3.
kono
parents:
diff changeset
294 -- A P in the example input string is an implied zero position,
kono
parents:
diff changeset
295 -- not included in the input string.
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297 else
kono
parents:
diff changeset
298 -- Round at correct position
kono
parents:
diff changeset
299 -- Input: 4PP => unchanged
kono
parents:
diff changeset
300 -- Input: 400.03 => unchanged
kono
parents:
diff changeset
301 -- Input 3.4567 => 3.457
kono
parents:
diff changeset
302 -- Input: 9.9999 => 10.000
kono
parents:
diff changeset
303 -- Input: 0.PPP5 => 0.001
kono
parents:
diff changeset
304 -- Input: 0.PPP4 => 0
kono
parents:
diff changeset
305 -- Input: 0.00003 => 0
kono
parents:
diff changeset
306
kono
parents:
diff changeset
307 Round (LD - (Scale - Digits_After_Point));
kono
parents:
diff changeset
308
kono
parents:
diff changeset
309 -- No digits before point in input
kono
parents:
diff changeset
310 -- Input: .123 Output: 0.123
kono
parents:
diff changeset
311 -- Input: .PP3 Output: 0.003
kono
parents:
diff changeset
312
kono
parents:
diff changeset
313 if Digits_Before_Point <= 0 then
kono
parents:
diff changeset
314 Set_Blanks_And_Sign (Fore - 1);
kono
parents:
diff changeset
315 Set ('0');
kono
parents:
diff changeset
316 Set ('.');
kono
parents:
diff changeset
317
kono
parents:
diff changeset
318 declare
kono
parents:
diff changeset
319 DA : Natural := Digits_After_Point;
kono
parents:
diff changeset
320 -- Digits remaining to output after point
kono
parents:
diff changeset
321
kono
parents:
diff changeset
322 LZ : constant Integer := Integer'Min (DA, -Digits_Before_Point);
kono
parents:
diff changeset
323 -- Number of leading zeroes after point. Note: there used to be
kono
parents:
diff changeset
324 -- a Max of this result with zero, but that's redundant, since
kono
parents:
diff changeset
325 -- we know DA is positive, and because of the test above, we
kono
parents:
diff changeset
326 -- know that -Digits_Before_Point >= 0.
kono
parents:
diff changeset
327
kono
parents:
diff changeset
328 begin
kono
parents:
diff changeset
329 Set_Zeroes (LZ);
kono
parents:
diff changeset
330 DA := DA - LZ;
kono
parents:
diff changeset
331
kono
parents:
diff changeset
332 if DA < ND then
kono
parents:
diff changeset
333
kono
parents:
diff changeset
334 -- Note: it is definitely possible for the above condition
kono
parents:
diff changeset
335 -- to be True, for example:
kono
parents:
diff changeset
336
kono
parents:
diff changeset
337 -- V => 1234, Scale => 5, Fore => 0, After => 1, Exp => 0
kono
parents:
diff changeset
338
kono
parents:
diff changeset
339 -- but in this case DA = 0, ND = 1, FD = 1, FD + DA-1 = 0
kono
parents:
diff changeset
340 -- so the arguments in the call are (1, 0) meaning that no
kono
parents:
diff changeset
341 -- digits are output.
kono
parents:
diff changeset
342
kono
parents:
diff changeset
343 -- No obvious example exists where the following call to
kono
parents:
diff changeset
344 -- Set_Digits actually outputs some digits, but we lack a
kono
parents:
diff changeset
345 -- proof that no such example exists.
kono
parents:
diff changeset
346
kono
parents:
diff changeset
347 -- So it is safer to retain this call, even though as a
kono
parents:
diff changeset
348 -- result it is hard (or perhaps impossible) to create a
kono
parents:
diff changeset
349 -- coverage test for the inlined code of the call.
kono
parents:
diff changeset
350
kono
parents:
diff changeset
351 Set_Digits (FD, FD + DA - 1);
kono
parents:
diff changeset
352
kono
parents:
diff changeset
353 else
kono
parents:
diff changeset
354 Set_Digits (FD, LD);
kono
parents:
diff changeset
355 Set_Zeroes (DA - ND);
kono
parents:
diff changeset
356 end if;
kono
parents:
diff changeset
357 end;
kono
parents:
diff changeset
358
kono
parents:
diff changeset
359 -- At least one digit before point in input
kono
parents:
diff changeset
360
kono
parents:
diff changeset
361 else
kono
parents:
diff changeset
362 -- Less digits in input than are needed before point
kono
parents:
diff changeset
363 -- Input: 1PP Output: 100.000
kono
parents:
diff changeset
364
kono
parents:
diff changeset
365 if ND < Digits_Before_Point then
kono
parents:
diff changeset
366
kono
parents:
diff changeset
367 -- Special case, if the input is the single digit 0, then we
kono
parents:
diff changeset
368 -- do not want 000.000, but instead 0.000.
kono
parents:
diff changeset
369
kono
parents:
diff changeset
370 if ND = 1 and then Digs (FD) = '0' then
kono
parents:
diff changeset
371 Set_Blanks_And_Sign (Fore - 1);
kono
parents:
diff changeset
372 Set ('0');
kono
parents:
diff changeset
373
kono
parents:
diff changeset
374 -- Normal case where we need to output scaling zeroes
kono
parents:
diff changeset
375
kono
parents:
diff changeset
376 else
kono
parents:
diff changeset
377 Set_Blanks_And_Sign (Fore - Digits_Before_Point);
kono
parents:
diff changeset
378 Set_Digits (FD, LD);
kono
parents:
diff changeset
379 Set_Zeroes (Digits_Before_Point - ND);
kono
parents:
diff changeset
380 end if;
kono
parents:
diff changeset
381
kono
parents:
diff changeset
382 -- Set period and zeroes after the period
kono
parents:
diff changeset
383
kono
parents:
diff changeset
384 Set ('.');
kono
parents:
diff changeset
385 Set_Zeroes (Digits_After_Point);
kono
parents:
diff changeset
386
kono
parents:
diff changeset
387 -- Input has full amount of digits before decimal point
kono
parents:
diff changeset
388
kono
parents:
diff changeset
389 else
kono
parents:
diff changeset
390 Set_Blanks_And_Sign (Fore - Digits_Before_Point);
kono
parents:
diff changeset
391 Set_Digits (FD, FD + Digits_Before_Point - 1);
kono
parents:
diff changeset
392 Set ('.');
kono
parents:
diff changeset
393 Set_Digits (FD + Digits_Before_Point, LD);
kono
parents:
diff changeset
394 Set_Zeroes (Digits_After_Point - (ND - Digits_Before_Point));
kono
parents:
diff changeset
395 end if;
kono
parents:
diff changeset
396 end if;
kono
parents:
diff changeset
397 end if;
kono
parents:
diff changeset
398 end Set_Decimal_Digits;
kono
parents:
diff changeset
399
kono
parents:
diff changeset
400 -----------------------
kono
parents:
diff changeset
401 -- Set_Image_Decimal --
kono
parents:
diff changeset
402 -----------------------
kono
parents:
diff changeset
403
kono
parents:
diff changeset
404 procedure Set_Image_Decimal
kono
parents:
diff changeset
405 (V : Integer;
kono
parents:
diff changeset
406 S : in out String;
kono
parents:
diff changeset
407 P : in out Natural;
kono
parents:
diff changeset
408 Scale : Integer;
kono
parents:
diff changeset
409 Fore : Natural;
kono
parents:
diff changeset
410 Aft : Natural;
kono
parents:
diff changeset
411 Exp : Natural)
kono
parents:
diff changeset
412 is
kono
parents:
diff changeset
413 Digs : String := Integer'Image (V);
kono
parents:
diff changeset
414 -- Sign and digits of decimal value
kono
parents:
diff changeset
415
kono
parents:
diff changeset
416 begin
kono
parents:
diff changeset
417 Set_Decimal_Digits (Digs, Digs'Length, S, P, Scale, Fore, Aft, Exp);
kono
parents:
diff changeset
418 end Set_Image_Decimal;
kono
parents:
diff changeset
419
kono
parents:
diff changeset
420 end System.Img_Dec;