File: RM-F.txt

package info (click to toggle)
ada-reference-manual 20021112web-3
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k, lenny, sarge
  • size: 18,652 kB
  • ctags: 8,921
  • sloc: makefile: 52; sh: 20
file content (1603 lines) | stat: -rw-r--r-- 41,386 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603


                                   Annex F
                                 (normative)

                             Information Systems


1     This Annex provides a set of facilities relevant to Information Systems
programming. These fall into several categories:

2     an attribute definition clause specifying Machine_Radix for a decimal
      subtype;

3     the package Decimal, which declares a set of constants defining the
      implementation's capacity for decimal types, and a generic procedure for
      decimal division; and

4     the child packages Text_IO.Editing and Wide_Text_IO.Editing, which
      support formatted and localized output of decimal data, based on ``
      picture String'' values.

5     See also: 3.5.9, ``Fixed Point Types''; 3.5.10, ``
Operations of Fixed Point Types''; 4.6, ``Type Conversions''; 13.3, ``
Operational and Representation Attributes''; A.10.9, ``
Input-Output for Real Types''; B.4, ``Interfacing with COBOL''; B.3, ``
Interfacing with C''; Annex G, ``Numerics''.

6     The character and string handling packages in Annex A, ``
Predefined Language Environment'' are also relevant for Information Systems.


                            Implementation Advice

7     If COBOL (respectively, C) is widely supported in the target
environment, implementations supporting the Information Systems Annex should
provide the child package Interfaces.COBOL (respectively, Interfaces.C)
specified in Annex B and should support a convention_identifier of COBOL
(respectively, C) in the interfacing pragmas (see Annex B), thus allowing Ada
programs to interface with programs written in that language.


F.1 Machine_Radix Attribute Definition Clause



                              Static Semantics

1     Machine_Radix may be specified for a decimal first subtype (see 3.5.9)
via an attribute_definition_clause; the expression of such a clause shall be
static, and its value shall be 2 or 10. A value of 2 implies a binary base
range; a value of 10 implies a decimal base range.


                            Implementation Advice

2     Packed decimal should be used as the internal representation for objects
of subtype S when S'Machine_Radix = 10.


                                  Examples

3     Example of Machine_Radix attribute definition clause:

4     type Money is delta 0.01 digits 15;
      for Money'Machine_Radix use 10;


F.2 The Package Decimal



                              Static Semantics

1     The library package Decimal has the following declaration:

2     package Ada.Decimal is
         pragma Pure(Decimal);

3        Max_Scale : constant := implementation-defined;
         Min_Scale : constant := implementation-defined;

4        Min_Delta : constant := 10.0**(-Max_Scale);
         Max_Delta : constant := 10.0**(-Min_Scale);

5        Max_Decimal_Digits : constant := implementation-defined;

6        generic
            type Dividend_Type  is delta <> digits <>;
            type Divisor_Type   is delta <> digits <>;
            type Quotient_Type  is delta <> digits <>;
            type Remainder_Type is delta <> digits <>;
         procedure Divide (Dividend  : in Dividend_Type;
                           Divisor   : in Divisor_Type;
                           Quotient  : out Quotient_Type;
                           Remainder : out Remainder_Type);
         pragma Convention(Intrinsic, Divide);

7     end Ada.Decimal;

8     Max_Scale is the largest N such that 10.0**(-N) is allowed as a decimal
type's delta. Its type is universal_integer.

9     Min_Scale is the smallest N such that 10.0**(-N) is allowed as a decimal
type's delta. Its type is universal_integer.

10    Min_Delta is the smallest value allowed for delta in a
decimal_fixed_point_definition. Its type is universal_real.

11    Max_Delta is the largest value allowed for delta in a
decimal_fixed_point_definition. Its type is universal_real.

12    Max_Decimal_Digits is the largest value allowed for digits in a
decimal_fixed_point_definition. Its type is universal_integer.


                              Static Semantics

13    The effect of Divide is as follows. The value of Quotient is
Quotient_Type(Dividend/Divisor). The value of Remainder is
Remainder_Type(Intermediate), where Intermediate is the difference between
Dividend and the product of Divisor and Quotient; this result is computed
exactly.


                         Implementation Requirements

14    Decimal.Max_Decimal_Digits shall be at least 18.

15    Decimal.Max_Scale shall be at least 18.

16    Decimal.Min_Scale shall be at most 0.

      NOTES

17    1  The effect of division yielding a quotient with control over rounding
      versus truncation is obtained by applying either the function attribute
      Quotient_Type'Round or the conversion Quotient_Type to the expression
      Dividend/Divisor.


F.3 Edited Output for Decimal Types


1     The child packages Text_IO.Editing and Wide_Text_IO.Editing provide
localizable formatted text output, known as edited output , for decimal types.
An edited output string is a function of a numeric value, program-specifiable
locale elements, and a format control value. The numeric value is of some
decimal type. The locale elements are:

2     the currency string;

3     the digits group separator character;

4     the radix mark character; and

5     the fill character that replaces leading zeros of the numeric value.

6     For Text_IO.Editing the edited output and currency strings are of type
String, and the locale characters are of type Character. For
Wide_Text_IO.Editing their types are Wide_String and Wide_Character,
respectively.

7     Each of the locale elements has a default value that can be replaced or
explicitly overridden.

8     A format-control value is of the private type Picture; it determines the
composition of the edited output string and controls the form and placement of
the sign, the position of the locale elements and the decimal digits, the
presence or absence of a radix mark, suppression of leading zeros, and
insertion of particular character values.

9     A Picture object is composed from a String value, known as a picture
String, that serves as a template for the edited output string, and a Boolean
value that controls whether a string of all space characters is produced when
the number's value is zero. A picture String comprises a sequence of one- or
two-Character symbols, each serving as a placeholder for a character or string
at a corresponding position in the edited output string. The picture String
symbols fall into several categories based on their effect on the edited
output string:

10      Decimal Digit:    '9'
        Radix Control:    '.'   'V'
        Sign Control:     '+'   '-'   '<'   '>'   "CR"  "DB"
        Currency Control:       '$'   '#'
        Zero Suppression:       'Z'   '*'
        Simple Insertion:       '_'   'B'   '0'   '/'

11    The entries are not case-sensitive. Mixed- or lower-case forms for "CR"
and "DB", and lower-case forms for 'V', 'Z', and 'B', have the same effect as
the upper-case symbols shown.

12    An occurrence of a '9' Character in the picture String represents a
decimal digit position in the edited output string.

13    A radix control Character in the picture String indicates the position
of the radix mark in the edited output string: an actual character position
for '.', or an assumed position for 'V'.

14    A sign control Character in the picture String affects the form of the
sign in the edited output string. The '<' and '>' Character values indicate
parentheses for negative values. A Character '+', '-', or '<' appears either
singly, signifying a fixed-position sign in the edited output, or repeated,
signifying a floating-position sign that is preceded by zero or more space
characters and that replaces a leading 0.

15    A currency control Character in the picture String indicates an
occurrence of the currency string in the edited output string. The '$'
Character represents the complete currency string; the '#' Character
represents one character of the currency string. A '$' Character appears
either singly, indicating a fixed-position currency string in the edited
output, or repeated, indicating a floating-position currency string that
occurs in place of a leading 0. A sequence of '#' Character values indicates
either a fixed- or floating-position currency string, depending on context.

16    A zero suppression Character in the picture String allows a leading zero
to be replaced by either the space character (for 'Z') or the fill character
(for '*').

17    A simple insertion Character in the picture String represents, in
general, either itself (if '/' or '0'), the space character (if 'B'), or the
digits group separator character (if '_'). In some contexts it is treated as
part of a floating sign, floating currency, or zero suppression string.

18    An example of a picture String is "<###Z_ZZ9.99>". If the currency
string is "FF", the separator character is ',', and the radix mark is '.' then
the edited output string values for the decimal values 32.10 and -5432.10 are
"bbFFbbb32.10b" and "(bFF5,432.10)", respectively, where 'b' indicates the
space character.

19    The generic packages Text_IO.Decimal_IO and Wide_Text_IO.Decimal_IO (see
A.10.9, ``Input-Output for Real Types'') provide text input and non-edited
text output for decimal types.

      NOTES

20    2  A picture String is of type Standard.String, both for Text_IO.Editing
      and Wide_Text_IO.Editing.


F.3.1 Picture String Formation


1     A well-formed picture String, or simply picture String, is a String
value that conforms to the syntactic rules, composition constraints, and
character replication conventions specified in this clause.


                              Dynamic Semantics

2/1   This paragraph was deleted.

3     picture_string ::=
         fixed_$_picture_string
       | fixed_#_picture_string
       | floating_currency_picture_string
       | non_currency_picture_string
      

4     fixed_$_picture_string ::=
         [fixed_LHS_sign] fixed_$_char {direct_insertion} [zero_suppression]
           number [RHS_sign]
      
       | [fixed_LHS_sign {direct_insertion}] [zero_suppression]
           number fixed_$_char {direct_insertion} [RHS_sign]
      
       | floating_LHS_sign number fixed_$_char {direct_insertion} [RHS_sign]
      
       | [fixed_LHS_sign] fixed_$_char {direct_insertion}
           all_zero_suppression_number {direct_insertion}  [RHS_sign]
      
       | [fixed_LHS_sign {direct_insertion}] all_zero_suppression_number {direct_insertion}
           fixed_$_char {direct_insertion} [RHS_sign]
      
       | all_sign_number {direct_insertion} fixed_$_char {direct_insertion} [RHS_sign]
      

5     fixed_#_picture_string ::=
         [fixed_LHS_sign] single_#_currency {direct_insertion}
           [zero_suppression] number [RHS_sign]
      
       | [fixed_LHS_sign] multiple_#_currency {direct_insertion}
           zero_suppression number [RHS_sign]
      
       | [fixed_LHS_sign {direct_insertion}] [zero_suppression]
           number fixed_#_currency {direct_insertion} [RHS_sign]
      
       | floating_LHS_sign number fixed_#_currency {direct_insertion} [RHS_sign]
      
       | [fixed_LHS_sign] single_#_currency {direct_insertion}
           all_zero_suppression_number {direct_insertion} [RHS_sign]
      
       | [fixed_LHS_sign] multiple_#_currency {direct_insertion}
           all_zero_suppression_number {direct_insertion} [RHS_sign]
      
       | [fixed_LHS_sign {direct_insertion}] all_zero_suppression_number {direct_insertion}
           fixed_#_currency {direct_insertion} [RHS_sign]
      
       | all_sign_number {direct_insertion} fixed_#_currency {direct_insertion} [RHS_sign]
      

6     floating_currency_picture_string ::=
         [fixed_LHS_sign] {direct_insertion} floating_$_currency number [RHS_sign]
       | [fixed_LHS_sign] {direct_insertion} floating_#_currency number [RHS_sign]
       | [fixed_LHS_sign] {direct_insertion} all_currency_number {direct_insertion} [RHS_sign]
      

7     non_currency_picture_string ::=
         [fixed_LHS_sign {direct_insertion}] zero_suppression number [RHS_sign]
       | [floating_LHS_sign] number [RHS_sign]
       | [fixed_LHS_sign {direct_insertion}] all_zero_suppression_number {direct_insertion}
           [RHS_sign]
       | all_sign_number {direct_insertion}
       | fixed_LHS_sign direct_insertion {direct_insertion} number [RHS_sign]
      

8     fixed_LHS_sign ::=  LHS_Sign

9     LHS_Sign ::=  + | - | <
      

10    fixed_$_char ::= $
      

11    direct_insertion ::=  simple_insertion

12    simple_insertion ::=  _ | B | 0 | /
      

13    zero_suppression ::=  Z {Z | context_sensitive_insertion} | fill_string

14    context_sensitive_insertion ::=  simple_insertion
      

15    fill_string ::=  * {* | context_sensitive_insertion}
      

16    number ::=
         fore_digits [radix [aft_digits] {direct_insertion}]
       | radix aft_digits {direct_insertion}

17    fore_digits ::= 9 {9 | direct_insertion}

18    aft_digits ::=  {9 | direct_insertion} 9

19    radix ::= . | V
      

20    RHS_sign ::= + | - | > | CR | DB
      

21    floating_LHS_sign ::=
         LHS_Sign {context_sensitive_insertion} LHS_Sign {LHS_Sign | context_sensitive_insertion}
      

22    single_#_currency ::= #

23    multiple_#_currency ::= ## {#}
      

24    fixed_#_currency ::= single_#_currency | multiple_#_currency
      

25    floating_$_currency ::=
         $ {context_sensitive_insertion} $ {$ | context_sensitive_insertion}
      

26    floating_#_currency ::=
         # {context_sensitive_insertion} # {# | context_sensitive_insertion}
      

27    all_sign_number ::=  all_sign_fore [radix [all_sign_aft]] [>]

28    all_sign_fore ::=
         sign_char {context_sensitive_insertion} sign_char {sign_char | context_sensitive_insertion}

29    all_sign_aft ::= {all_sign_aft_char} sign_char
      
      all_sign_aft_char ::=  sign_char | context_sensitive_insertion

30    sign_char ::= + | - | <
      

31    all_currency_number ::=  all_currency_fore [radix [all_currency_aft]]

32    all_currency_fore ::=
         currency_char {context_sensitive_insertion}
           currency_char {currency_char | context_sensitive_insertion}

33    all_currency_aft ::= {all_currency_aft_char} currency_char
      
      all_currency_aft_char ::= currency_char | context_sensitive_insertion

34    currency_char ::= $ | #
      

35    all_zero_suppression_number ::=  all_zero_suppression_fore [ radix [all_zero_suppression_aft]]

36    all_zero_suppression_fore ::=
         zero_suppression_char {zero_suppression_char | context_sensitive_insertion}

37    all_zero_suppression_aft ::= {all_zero_suppression_aft_char} zero_suppression_char
      
      all_zero_suppression_aft_char ::=  zero_suppression_char | context_sensitive_insertion

38    zero_suppression_char ::= Z | *

39    The following composition constraints apply to a picture String:

40    A floating_LHS_sign does not have occurrences of different LHS_Sign
      Character values.

41    If a picture String has '<' as fixed_LHS_sign, then it has '>' as
      RHS_sign.

42    If a picture String has '<' in a floating_LHS_sign or in an
      all_sign_number, then it has an occurrence of '>'.

43/1  If a picture String has '+' or '-' as fixed_LHS_sign, in a
      floating_LHS_sign, or in an all_sign_number, then it has no RHS_sign or
      '>' character.

44    An instance of all_sign_number does not have occurrences of different
      sign_char Character values.

45    An instance of all_currency_number does not have occurrences of
      different currency_char Character values.

46    An instance of all_zero_suppression_number does not have occurrences of
      different zero_suppression_char Character values, except for possible
      case differences between 'Z' and 'z'.

47    A replicable Character is a Character that, by the above rules, can
occur in two consecutive positions in a picture String.

48    A Character replication is a String

49    char & '(' & spaces & count_string & ')'

50    where char is a replicable Character, spaces is a String (possibly
empty) comprising only space Character values, and count_string is a String of
one or more decimal digit Character values. A Character replication in a
picture String has the same effect as (and is said to be equivalent to) a
String comprising n consecutive occurrences of char, where
n=Integer'Value(count_string).

51    An expanded picture String is a picture String containing no Character
replications.

      NOTES

52    3  Although a sign to the left of the number can float, a sign to the
      right of the number is in a fixed position.


F.3.2 Edited Output Generation



                              Dynamic Semantics

1     The contents of an edited output string are based on:

2     A value, Item, of some decimal type Num,

3     An expanded picture String Pic_String,

4     A Boolean value, Blank_When_Zero,

5     A Currency string,

6     A Fill character,

7     A Separator character, and

8     A Radix_Mark character.

9     The combination of a True value for Blank_When_Zero and a '*' character
in Pic_String is inconsistent; no edited output string is defined.

10    A layout error is identified in the rules below if leading non-zero
digits of Item, character values of the Currency string, or a negative sign
would be truncated; in such cases no edited output string is defined.

11    The edited output string has lower bound 1 and upper bound N where N =
Pic_String'Length + Currency_Length_Adjustment - Radix_Adjustment, and

12    Currency_Length_Adjustment = Currency'Length - 1 if there is some
      occurrence of '$' in Pic_String, and 0 otherwise.

13    Radix_Adjustment = 1 if there is an occurrence of 'V' or 'v' in Pic_Str,
      and 0 otherwise.

14    Let the magnitude of Item be expressed as a base-10 number
I(p)I(1).F(1)F(q), called the displayed magnitude of Item, where:

15    q = Min(Max(Num'Scale, 0), n) where n is 0 if Pic_String has no radix
      and is otherwise the number of digit positions following radix in
      Pic_String, where a digit position corresponds to an occurrence of '9',
      a zero_suppression_char (for an all_zero_suppression_number), a
      currency_char (for an all_currency_number), or a sign_char (for an
      all_sign_number).

16    I(p) /= 0 if p>0.

17    If n < Num'Scale, then the above number is the result of rounding (away
from 0 if exactly midway between values).

18    If Blank_When_Zero = True and the displayed magnitude of Item is zero,
then the edited output string comprises all space character values. Otherwise,
the picture String is treated as a sequence of instances of syntactic
categories based on the rules in F.3.1, and the edited output string is the
concatenation of string values derived from these categories according to the
following mapping rules.

19    Table F-1 shows the mapping from a sign control symbol to a
corresponding character or string in the edited output. In the columns showing
the edited output, a lower-case 'b' represents the space character. If there
is no sign control symbol but the value of Item is negative, a layout error
occurs and no edited output string is produced.

          Table F-1: Edited Output for Sign Control Symbols

          Sign Control Symbol 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

          Edited Output for
          Non-Negative Number 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

          Edited Output for
          Negative Number

          '+' 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
'+' 

          '-'
          '-' 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
'b' 

          '-'
          '<' 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
'b' 

          '('
          '>' 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
'b' 

          ')'
          "CR" 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

          "bb" 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

          "CR"
          "DB" 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

          "bb" 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

          "DB"
20    An instance of fixed_LHS_sign maps to a character as shown in Table F-1.

21    An instance of fixed_$_char maps to Currency.

22    An instance of direct_insertion maps to Separator if direct_insertion =
'_', and to the direct_insertion Character otherwise.

23    An instance of number maps to a string integer_part & radix_part &
fraction_part where:

24    The string for integer_part is obtained as follows:

    25    1.  Occurrences of '9' in fore_digits of number are replaced from
              right to left with the decimal digit character values for I(1),
              ..., I(p), respectively.

    26    2.  Each occurrence of '9' in fore_digits to the left of the
              leftmost '9' replaced according to rule 1 is replaced with '0'.

    27    3.  If p exceeds the number of occurrences of '9' in fore_digits of
              number, then the excess leftmost digits are eligible for use in
              the mapping of an instance of zero_suppression,
              floating_LHS_sign, floating_$_currency, or floating_#_currency
              to the left of number; if there is no such instance, then a
              layout error occurs and no edited output string is produced.

28    The radix_part is:

    29    "" if number does not include a radix, if radix = 'V', or if radix =
          'v'

    30    Radix_Mark if number includes '.' as radix

31    The string for fraction_part is obtained as follows:

    32    1.  Occurrences of '9' in aft_digits of number are replaced from
              left to right with the decimal digit character values for F(1),
              ... F(q).

    33    2.  Each occurrence of '9' in aft_digits to the right of the
              rightmost '9' replaced according to rule 1 is replaced by '0'.

34    An instance of zero_suppression maps to the string obtained as follows:

35    1.  The rightmost 'Z', 'z', or '*' Character values are replaced with
          the excess digits (if any) from the integer_part of the mapping of
          the number to the right of the zero_suppression instance,

36    2.  A context_sensitive_insertion Character is replaced as though it
          were a direct_insertion Character, if it occurs to the right of some
          'Z', 'z', or '*' in zero_suppression that has been mapped to an
          excess digit,

37    3.  Each Character to the left of the leftmost Character replaced
          according to rule 1 above is replaced by:

    38    the space character if the zero suppression Character is 'Z' or 'z',
          or

    39    the Fill character if the zero suppression Character is '*'.

40    4.  A layout error occurs if some excess digits remain after all 'Z',
          'z', and '*' Character values in zero_suppression have been replaced
          via rule 1; no edited output string is produced.

41    An instance of RHS_sign maps to a character or string as shown in Table
F-1.

42    An instance of floating_LHS_sign maps to the string obtained as follows.

43    1.  Up to all but one of the rightmost LHS_Sign Character values are
          replaced by the excess digits (if any) from the integer_part of the
          mapping of the number to the right of the floating_LHS_sign instance.

44    2.  The next Character to the left is replaced with the character given
          by the entry in Table F-1 corresponding to the LHS_Sign Character.

45    3.  A context_sensitive_insertion Character is replaced as though it
          were a direct_insertion Character, if it occurs to the right of the
          leftmost LHS_Sign character replaced according to rule 1.

46    4.  Any other Character is replaced by the space character..

47    5.  A layout error occurs if some excess digits remain after replacement
          via rule 1; no edited output string is produced.

48    An instance of fixed_#_currency maps to the Currency string with n space
character values concatenated on the left (if the instance does not follow a
radix) or on the right (if the instance does follow a radix), where n is the
difference between the length of the fixed_#_currency instance and
Currency'Length. A layout error occurs if Currency'Length exceeds the length
of the fixed_#_currency instance; no edited output string is produced.

49    An instance of floating_$_currency maps to the string obtained as
follows:

50    1.  Up to all but one of the rightmost '$' Character values are replaced
          with the excess digits (if any) from the integer_part of the mapping
          of the number to the right of the floating_$_currency instance.

51    2.  The next Character to the left is replaced by the Currency string.

52    3.  A context_sensitive_insertion Character is replaced as though it
          were a direct_insertion Character, if it occurs to the right of the
          leftmost '$' Character replaced via rule 1.

53    4.  Each other Character is replaced by the space character.

54    5.  A layout error occurs if some excess digits remain after replacement
          by rule 1; no edited output string is produced.

55    An instance of floating_#_currency maps to the string obtained as
follows:

56    1.  Up to all but one of the rightmost '#' Character values are replaced
          with the excess digits (if any) from the integer_part of the mapping
          of the number to the right of the floating_#_currency instance.

57    2.  The substring whose last Character occurs at the position
          immediately preceding the leftmost Character replaced via rule 1,
          and whose length is Currency'Length, is replaced by the Currency
          string.

58    3.  A context_sensitive_insertion Character is replaced as though it
          were a direct_insertion Character, if it occurs to the right of the
          leftmost '#' replaced via rule 1.

59    4.  Any other Character is replaced by the space character.

60    5.  A layout error occurs if some excess digits remain after replacement
          rule 1, or if there is no substring with the required length for
          replacement rule 2; no edited output string is produced.

61    An instance of all_zero_suppression_number maps to:

62    a string of all spaces if the displayed magnitude of Item is zero, the
      zero_suppression_char is 'Z' or 'z', and the instance of
      all_zero_suppression_number does not have a radix at its last character
      position;

63    a string containing the Fill character in each position except for the
      character (if any) corresponding to radix, if zero_suppression_char =
      '*' and the displayed magnitude of Item is zero;

64    otherwise, the same result as if each zero_suppression_char in
      all_zero_suppression_aft were '9', interpreting the instance of
      all_zero_suppression_number as either zero_suppression number (if a
      radix and all_zero_suppression_aft are present), or as zero_suppression
      otherwise.

65    An instance of all_sign_number maps to:

66    a string of all spaces if the displayed magnitude of Item is zero and
      the instance of all_sign_number does not have a radix at its last
      character position;

67    otherwise, the same result as if each sign_char in all_sign_number_aft
      were '9', interpreting the instance of all_sign_number as either
      floating_LHS_sign number (if a radix and all_sign_number_aft are
      present), or as floating_LHS_sign otherwise.

68    An instance of all_currency_number maps to:

69    a string of all spaces if the displayed magnitude of Item is zero and
      the instance of all_currency_number does not have a radix at its last
      character position;

70    otherwise, the same result as if each currency_char in
      all_currency_number_aft were '9', interpreting the instance of
      all_currency_number as floating_$_currency number or floating_#_currency
      number (if a radix and all_currency_number_aft are present), or as
      floating_$_currency or floating_#_currency otherwise.


                                  Examples

71    In the result string values shown below, 'b' represents the space
character.

72    Item:         Picture and Result Strings:

73    123456.78     Picture:  "-###**_***_**9.99"
                              "bbb$***123,456.78"
                              "bbFF***123.456,78" (currency = "FF",
                                                   separator = '.',
                                                   radix mark = ',')

74/1  123456.78     Picture:  "-$**_***_**9.99"
                    Result:   "b$***123,456.78"
                             "bFF***123.456,78" (currency = "FF",
                                                 separator = '.',
                                                 radix mark = ',')

75    0.0          Picture: "-$$$$$$.$$"
                   Result:  "bbbbbbbbbb"

76    0.20         Picture: "-$$$$$$.$$"
                   Result:  "bbbbbb$.20"

77    -1234.565    Picture: "<<<<_<<<.<<###>"
                   Result:  "bb(1,234.57DMb)"  (currency = "DM")

78    12345.67     Picture: "###_###_##9.99"
                   Result:  "bbCHF12,345.67"   (currency = "CHF")


F.3.3 The Package Text_IO.Editing


1     The package Text_IO.Editing provides a private type Picture with
associated operations, and a generic package Decimal_Output. An object of type
Picture is composed from a well-formed picture String (see F.3.1) and a
Boolean item indicating whether a zero numeric value will result in an edited
output string of all space characters. The package Decimal_Output contains
edited output subprograms implementing the effects defined in F.3.2.


                              Static Semantics

2     The library package Text_IO.Editing has the following declaration:

3     package Ada.Text_IO.Editing is

4        type Picture is private;

5        function Valid (Pic_String      : in String;
                         Blank_When_Zero : in Boolean := False) return Boolean;

6        function To_Picture (Pic_String      : in String;
                              Blank_When_Zero : in Boolean := False)
            return Picture;

7        function Pic_String      (Pic : in Picture) return String;
         function Blank_When_Zero (Pic : in Picture) return Boolean;

8        Max_Picture_Length  : constant := implementation_defined;

9        Picture_Error       : exception;

10       Default_Currency    : constant String    := "$";
         Default_Fill        : constant Character := '*';
         Default_Separator   : constant Character := ',';
         Default_Radix_Mark  : constant Character := '.';

11       generic
            type Num is delta <> digits <>;
            Default_Currency   : in String    := Text_IO.Editing.Default_Currency;
            Default_Fill       : in Character := Text_IO.Editing.Default_Fill;
            Default_Separator  : in Character :=
                                    Text_IO.Editing.Default_Separator;
            Default_Radix_Mark : in Character :=
                                    Text_IO.Editing.Default_Radix_Mark;
         package Decimal_Output is
            function Length (Pic      : in Picture;
                             Currency : in String := Default_Currency)
               return Natural;

12          function Valid (Item     : in Num;
                            Pic      : in Picture;
                            Currency : in String := Default_Currency)
               return Boolean;

13          function Image (Item       : in Num;
                            Pic        : in Picture;
                            Currency   : in String    := Default_Currency;
                            Fill       : in Character := Default_Fill;
                            Separator  : in Character := Default_Separator;
                            Radix_Mark : in Character := Default_Radix_Mark)
               return String;

14          procedure Put (File       : in File_Type;
                           Item       : in Num;
                           Pic        : in Picture;
                           Currency   : in String    := Default_Currency;
                           Fill       : in Character := Default_Fill;
                           Separator  : in Character := Default_Separator;
                           Radix_Mark : in Character := Default_Radix_Mark);

15          procedure Put (Item       : in Num;
                           Pic        : in Picture;
                           Currency   : in String    := Default_Currency;
                           Fill       : in Character := Default_Fill;
                           Separator  : in Character := Default_Separator;
                           Radix_Mark : in Character := Default_Radix_Mark);

16          procedure Put (To         : out String;
                           Item       : in Num;
                           Pic        : in Picture;
                           Currency   : in String    := Default_Currency;
                           Fill       : in Character := Default_Fill;
                           Separator  : in Character := Default_Separator;
                           Radix_Mark : in Character := Default_Radix_Mark);
         end Decimal_Output;
      private
         ... -- not specified by the language
      end Ada.Text_IO.Editing;

17    The exception Constraint_Error is raised if the Image function or any of
the Put procedures is invoked with a null string for Currency.

18    function Valid (Pic_String      : in String;
                      Blank_When_Zero : in Boolean := False) return Boolean;

    19    Valid returns True if Pic_String is a well-formed picture String
          (see F.3.1) the length of whose expansion does not exceed
          Max_Picture_Length, and if either Blank_When_Zero is False or
          Pic_String contains no '*'.

20    function To_Picture (Pic_String      : in String;
                           Blank_When_Zero : in Boolean := False)
         return Picture;

    21    To_Picture returns a result Picture such that the application of the
          function Pic_String to this result yields an expanded picture String
          equivalent to Pic_String, and such that Blank_When_Zero applied to
          the result Picture is the same value as the parameter
          Blank_When_Zero. Picture_Error is raised if not Valid(Pic_String,
          Blank_When_Zero).

22    function Pic_String      (Pic : in Picture) return String;
      
      function Blank_When_Zero (Pic : in Picture) return Boolean;

    23    If Pic is To_Picture(String_Item, Boolean_Item) for some String_Item
          and Boolean_Item, then:

        24    Pic_String(Pic) returns an expanded picture String equivalent to
              String_Item and with any lower-case letter replaced with its
              corresponding upper-case form, and

        25    Blank_When_Zero(Pic) returns Boolean_Item.

    26    If Pic_1 and Pic_2 are objects of type Picture, then "="(Pic_1,
          Pic_2) is True when

        27    Pic_String(Pic_1) = Pic_String(Pic_2), and

        28    Blank_When_Zero(Pic_1) = Blank_When_Zero(Pic_2).

29    function Length (Pic      : in Picture;
                       Currency : in String := Default_Currency)
         return Natural;

    30    Length returns Pic_String(Pic)'Length + Currency_Length_Adjustment -
          Radix_Adjustment where

        31    Currency_Length_Adjustment =

            32    Currency'Length - 1 if there is some occurrence of '$' in
                  Pic_String(Pic), and

            33    0 otherwise.

        34    Radix_Adjustment =

            35    1 if there is an occurrence of 'V' or 'v' in Pic_Str(Pic),
                  and

            36    0 otherwise.

37    function Valid (Item     : in Num;
                      Pic      : in Picture;
                      Currency : in String := Default_Currency)
         return Boolean;

    38    Valid returns True if Image(Item, Pic, Currency) does not raise
          Layout_Error, and returns False otherwise.

39    function Image (Item       : in Num;
                      Pic        : in Picture;
                      Currency   : in String    := Default_Currency;
                      Fill       : in Character := Default_Fill;
                      Separator  : in Character := Default_Separator;
                      Radix_Mark : in Character := Default_Radix_Mark)
         return String;

    40    Image returns the edited output String as defined in F.3.2 for Item,
          Pic_String(Pic), Blank_When_Zero(Pic), Currency, Fill, Separator,
          and Radix_Mark. If these rules identify a layout error, then Image
          raises the exception Layout_Error.

41    procedure Put (File       : in File_Type;
                     Item       : in Num;
                     Pic        : in Picture;
                     Currency   : in String    := Default_Currency;
                     Fill       : in Character := Default_Fill;
                     Separator  : in Character := Default_Separator;
                     Radix_Mark : in Character := Default_Radix_Mark);
      
      procedure Put (Item       : in Num;
                     Pic        : in Picture;
                     Currency   : in String    := Default_Currency;
                     Fill       : in Character := Default_Fill;
                     Separator  : in Character := Default_Separator;
                     Radix_Mark : in Character := Default_Radix_Mark);

    42    Each of these Put procedures outputs Image(Item, Pic, Currency,
          Fill, Separator, Radix_Mark) consistent with the conventions for Put
          for other real types in case of bounded line length (see A.10.6, 
          ``Get and Put Procedures'').

43    procedure Put (To         : out String;
                     Item       : in Num;
                     Pic        : in Picture;
                     Currency   : in String    := Default_Currency;
                     Fill       : in Character := Default_Fill;
                     Separator  : in Character := Default_Separator;
                     Radix_Mark : in Character := Default_Radix_Mark);

    44    Put copies Image(Item, Pic, Currency, Fill, Separator, Radix_Mark)
          to the given string, right justified. Otherwise unassigned Character
          values in To are assigned the space character. If To'Length is less
          than the length of the string resulting from Image, then
          Layout_Error is raised.


                         Implementation Requirements

45    Max_Picture_Length shall be at least 30. The implementation shall
support currency strings of length up to at least 10, both for
Default_Currency in an instantiation of Decimal_Output, and for Currency in an
invocation of Image or any of the Put procedures.

      NOTES

46    4  The rules for edited output are based on COBOL (ANSI X3.23:1985,
      endorsed by ISO as ISO 1989-1985), with the following differences:

    47    The COBOL provisions for picture string localization and for 'P'
          format are absent from Ada.

    48    The following Ada facilities are not in COBOL:

        49    currency symbol placement after the number,

        50    localization of edited output string for multi-character
              currency string values, including support for both
              length-preserving and length-expanding currency symbols in
              picture strings

        51    localization of the radix mark, digits separator, and fill
              character, and

        52    parenthesization of negative values.

52.1  The value of 30 for Max_Picture_Length is the same limit as in COBOL.


F.3.4 The Package Wide_Text_IO.Editing



                              Static Semantics

1     The child package Wide_Text_IO.Editing has the same contents as
Text_IO.Editing, except that:

2     each occurrence of Character is replaced by Wide_Character,

3     each occurrence of Text_IO is replaced by Wide_Text_IO,

4     the subtype of Default_Currency is Wide_String rather than String, and

5     each occurrence of String in the generic package Decimal_Output is
      replaced by Wide_String.

      NOTES

6     5  Each of the functions Wide_Text_IO.Editing.Valid, To_Picture, and
      Pic_String has String (versus Wide_String) as its parameter or result
      subtype, since a picture String is not localizable.