| 1 |
@comment{ $Source: e:\\cvsroot/ARM/Source/infosys.mss,v $ } |
| 2 |
@comment{ $Revision: 1.46 $ $Date: 2018/09/05 05:22:38 $ $Author: randy $ } |
| 3 |
@Part(infosys, Root="ada.mss") |
| 4 |
|
| 5 |
@Comment{$Date: 2018/09/05 05:22:38 $} |
| 6 |
@LabeledNormativeAnnex{Information Systems} |
| 7 |
|
| 8 |
@begin{Intro} |
| 9 |
@Defn{information systems} |
| 10 |
@Leading@;This Annex provides a set of facilities relevant to |
| 11 |
Information Systems programming. These fall into several |
| 12 |
categories: |
| 13 |
@begin{itemize} |
| 14 |
an attribute definition clause specifying Machine_Radix for a decimal subtype; |
| 15 |
|
| 16 |
the package Decimal, which declares a set of constants defining the |
| 17 |
implementation's capacity for decimal types, and a |
| 18 |
generic procedure |
| 19 |
for decimal division; and |
| 20 |
|
| 21 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00285-01]} |
| 22 |
the child packages Text_IO.Editing@Chg{Version=[2],New=[,],Old=[ and]} |
| 23 |
Wide_Text_IO.Editing@Chg{Version=[2],New=[, and Wide_Wide_Text_IO.Editing],Old=[]}, |
| 24 |
which |
| 25 |
support formatted and localized output of decimal data, based on |
| 26 |
@lquotes@;picture String@rquotes@; values. |
| 27 |
@end{itemize} |
| 28 |
|
| 29 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00434-01]} |
| 30 |
See also: @RefSec{Fixed Point Types}; @RefSec{Operations of Fixed Point Types}; |
| 31 |
@RefSec{Type Conversions}; |
| 32 |
@RefSec{Operational and Representation Attributes}; |
| 33 |
@RefSec(Input-Output for Real Types);@Chg{Version=[2], |
| 34 |
New=[],Old=[@RefSec{Interfacing with COBOL};]} |
| 35 |
@RefSec{Interfacing with C and C++};@Chg{Version=[2], |
| 36 |
New=[ @RefSec{Interfacing with COBOL};],Old=[]} |
| 37 |
@RefSec{Numerics}. |
| 38 |
|
| 39 |
The character and string handling packages in |
| 40 |
@RefSec{Predefined Language Environment} |
| 41 |
are also relevant for Information Systems. |
| 42 |
@end{Intro} |
| 43 |
|
| 44 |
@begin{ImplAdvice} |
| 45 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]} |
| 46 |
If COBOL (respectively, C) is widely supported in the target environment, |
| 47 |
implementations supporting the Information Systems |
| 48 |
Annex should provide the child package |
| 49 |
Interfaces.COBOL (respectively, Interfaces.C) specified in |
| 50 |
@RefSecNum{Interface to Other Languages} |
| 51 |
and should support a @i{convention_}@nt{identifier} of |
| 52 |
COBOL (respectively, C) @Chg{Version=[3],New=[for],Old=[in]} the |
| 53 |
@Chg{Version=[3],New=[Convention aspect],Old=[interfacing pragmas]} |
| 54 |
(see @RefSecNum{Interface to Other Languages}), |
| 55 |
thus allowing Ada programs to interface with programs written in |
| 56 |
that language. |
| 57 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 58 |
Text=[If COBOL (respectively, C) is supported in the target environment, |
| 59 |
then interfacing to COBOL (respectively, C) should be supported as |
| 60 |
specified in @RefSecNum{Interface to Other Languages}.]}]} |
| 61 |
@end{ImplAdvice} |
| 62 |
|
| 63 |
@begin{Extend83} |
| 64 |
@Defn{extensions to Ada 83} |
| 65 |
This Annex is new to Ada 95. |
| 66 |
@end{Extend83} |
| 67 |
|
| 68 |
@begin{DiffWord95} |
| 69 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]} |
| 70 |
@ChgAdded{Version=[2],Text=[Added a mention of Wide_Wide_Text_IO.Editing, |
| 71 |
part of the support for 32-bit characters.]} |
| 72 |
@end{DiffWord95} |
| 73 |
|
| 74 |
@LabeledClause{Machine_Radix Attribute Definition Clause} |
| 75 |
|
| 76 |
@begin{StaticSem} |
| 77 |
@ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0272-1]} |
| 78 |
@PDefn2{Term=[specifiable], Sec=(of Machine_Radix for decimal first subtypes)} |
| 79 |
@Defn{Machine_Radix clause} |
| 80 |
@Chg{Version=[5],New=[The representation attribute ],Old=[]}Machine_Radix |
| 81 |
may be specified for a decimal first subtype |
| 82 |
(see @RefSecNum{Fixed Point Types}) |
| 83 |
via an @nt{attribute_definition_clause}; |
| 84 |
the expression of such a clause shall be static, |
| 85 |
and its value shall be 2 or 10. |
| 86 |
A value of 2 implies a binary base range; a |
| 87 |
value of 10 implies a decimal base range.@Chg{Version=[3],New=[@AspectDefn{Machine_Radix}],Old=[]} |
| 88 |
@begin{Ramification} |
| 89 |
In the absence of a Machine_Radix clause, the choice |
| 90 |
of 2 versus 10 for S'Machine_Radix is not specified. |
| 91 |
@end{Ramification} |
| 92 |
|
| 93 |
@ChgAspectDesc{Version=[3],Kind=[AddedNormal],Aspect=[Machine_Radix], |
| 94 |
Text=[@ChgAdded{Version=[3],Text=[Radix (2 or 10) that is used to |
| 95 |
represent a decimal fixed point type.]}]} |
| 96 |
|
| 97 |
@end{StaticSem} |
| 98 |
|
| 99 |
@begin{ImplAdvice} |
| 100 |
Packed decimal should be used as the internal representation |
| 101 |
for objects of subtype S when S'Machine_Radix = 10. |
| 102 |
@ChgImplAdvice{Version=[2],Kind=[AddedNormal],Text=[@ChgAdded{Version=[2], |
| 103 |
Text=[Packed decimal should be used as the internal representation |
| 104 |
for objects of subtype @i<S> when @i<S>'Machine_Radix = 10.]}]} |
| 105 |
@end{ImplAdvice} |
| 106 |
|
| 107 |
@begin{Discussion} |
| 108 |
|
| 109 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]} |
| 110 |
The intent of a decimal Machine_Radix attribute definition clause |
| 111 |
is to allow the programmer to declare an Ada decimal data object |
| 112 |
whose representation matches a particular COBOL implementation's |
| 113 |
representation of packed decimal items. |
| 114 |
The Ada object may then be passed to an interfaced COBOL program |
| 115 |
that takes a packed decimal data item as a parameter, |
| 116 |
assuming that convention COBOL has been specified for the Ada |
| 117 |
object's type @Chg{Version=[3],New=[with an aspect],Old=[in a @nt[pragma]]} |
| 118 |
Convention. |
| 119 |
|
| 120 |
Additionally, the Ada compiler may choose to generate arithmetic |
| 121 |
instructions that exploit the packed decimal representation. |
| 122 |
|
| 123 |
@end{discussion} |
| 124 |
|
| 125 |
@begin{Examples} |
| 126 |
@Leading@Keepnext@i{Example of Machine_Radix attribute definition clause:} |
| 127 |
@begin{example} |
| 128 |
@key[type] Money @key[is] @key[delta] 0.01 @key[digits] 15; |
| 129 |
@key[for] Money'Machine_Radix @key[use] 10; |
| 130 |
@end{example} |
| 131 |
@end{Examples} |
| 132 |
|
| 133 |
@begin{DiffWord2012} |
| 134 |
@ChgRef{Version=[5],Kind=[AddedNormal],ARef=[AI12-0272-1]} |
| 135 |
@ChgAdded{Version=[5],Text=[Clarified that Machine_Radix is a representation |
| 136 |
aspect.]} |
| 137 |
@end{DiffWord2012} |
| 138 |
|
| 139 |
|
| 140 |
@LabeledClause{The Package Decimal} |
| 141 |
|
| 142 |
@begin{StaticSem} |
| 143 |
@Leading@Keepnext@;The library package Decimal has the following declaration: |
| 144 |
@begin{Example} |
| 145 |
@key(package) Ada.Decimal @key(is)@ChildUnit{Parent=[Ada],Child=[Decimal]} |
| 146 |
@key(pragma) Pure(Decimal); |
| 147 |
|
| 148 |
@AdaObjDefn{Max_Scale} : @key(constant) := @RI{implementation-defined}; |
| 149 |
@AdaObjDefn{Min_Scale} : @key(constant) := @RI{implementation-defined}; |
| 150 |
|
| 151 |
@AdaObjDefn{Min_Delta} : @key(constant) := 10.0**(-Max_Scale); |
| 152 |
@AdaObjDefn{Max_Delta} : @key(constant) := 10.0**(-Min_Scale); |
| 153 |
|
| 154 |
@AdaObjDefn{Max_Decimal_Digits} : @key(constant) := @RI{implementation-defined}; |
| 155 |
|
| 156 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0229-1]} |
| 157 |
@key(generic) |
| 158 |
@key(type) Dividend_Type @key(is) @key(delta) <> @key(digits) <>; |
| 159 |
@key(type) Divisor_Type @key(is) @key(delta) <> @key(digits) <>; |
| 160 |
@key(type) Quotient_Type @key(is) @key(delta) <> @key(digits) <>; |
| 161 |
@key(type) Remainder_Type @key(is) @key(delta) <> @key(digits) <>; |
| 162 |
@key(procedure) @AdaSubDefn{Divide} (Dividend : @key(in) Dividend_Type; |
| 163 |
Divisor : @key(in) Divisor_Type; |
| 164 |
Quotient : @key(out) Quotient_Type; |
| 165 |
Remainder : @key(out) Remainder_Type)@Chg{Version=[3],New=[ |
| 166 |
@key(with) Convention => Intrinsic],Old=[; |
| 167 |
@key[pragma] Convention(Intrinsic, Divide)]}; |
| 168 |
|
| 169 |
@key(end) Ada.Decimal; |
| 170 |
@end{Example} |
| 171 |
@ImplDef{The values of named numbers in the package Decimal.} |
| 172 |
|
| 173 |
Max_Scale is the largest N such that 10.0**(@en@;N) is allowed as a decimal |
| 174 |
type's delta. Its type is @i{universal_integer}. |
| 175 |
|
| 176 |
Min_Scale is the smallest N such that 10.0**(@en@;N) is allowed as a decimal |
| 177 |
type's delta. Its type is @i{universal_integer}. |
| 178 |
|
| 179 |
Min_Delta is the smallest value allowed for @i{delta} in a |
| 180 |
@nt{decimal_fixed_point_definition}. Its type is @i{universal_real}. |
| 181 |
|
| 182 |
Max_Delta is the largest value allowed for @i{delta} in a |
| 183 |
@nt{decimal_fixed_point_definition}. Its type is @i{universal_real}. |
| 184 |
|
| 185 |
Max_Decimal_Digits is the largest value allowed for @i{digits} in a |
| 186 |
@nt{decimal_fixed_point_definition}. Its type is @i{universal_integer}. |
| 187 |
@begin{reason} |
| 188 |
The name is Max_Decimal_Digits versus Max_Digits, in order to avoid |
| 189 |
confusion with the named number System.Max_Digits relevant to floating |
| 190 |
point. |
| 191 |
@end{reason} |
| 192 |
@end{StaticSem} |
| 193 |
|
| 194 |
@begin{StaticSem} |
| 195 |
The effect of Divide is as follows. |
| 196 |
The value of Quotient is Quotient_Type(Dividend/Divisor). |
| 197 |
The value of Remainder is Remainder_Type(Intermediate), |
| 198 |
where Intermediate is the difference between Dividend and the product of |
| 199 |
Divisor and Quotient; this result is computed exactly. |
| 200 |
@end{StaticSem} |
| 201 |
|
| 202 |
@begin(ImplReq) |
| 203 |
Decimal.Max_Decimal_Digits shall be at least 18. |
| 204 |
|
| 205 |
Decimal.Max_Scale shall be at least 18. |
| 206 |
|
| 207 |
Decimal.Min_Scale shall be at most 0. |
| 208 |
@end{ImplReq} |
| 209 |
|
| 210 |
@begin(Notes) |
| 211 |
The effect of division yielding a quotient with control over rounding |
| 212 |
versus truncation is obtained by applying either the |
| 213 |
function attribute Quotient_Type'Round or the conversion Quotient_Type |
| 214 |
to the expression Dividend/Divisor. |
| 215 |
@end(Notes) |
| 216 |
|
| 217 |
|
| 218 |
@LabeledClause{Edited Output for Decimal Types} |
| 219 |
@begin{Intro} |
| 220 |
@Leading@; |
| 221 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00285-01]} |
| 222 |
The child packages Text_IO.Editing@Chg{Version=[2],New=[,],Old=[ and]} |
| 223 |
Wide_Text_IO.Editing@Chg{Version=[2],New=[, and Wide_Wide_Text_IO.Editing],Old=[]} |
| 224 |
provide localizable formatted text |
| 225 |
output, known as @i{edited output}@Defn{edited output}, |
| 226 |
for decimal types. An edited |
| 227 |
output string is a function of a numeric value, program-specifiable |
| 228 |
locale elements, and a format control value. The numeric value is of |
| 229 |
some decimal type. The locale elements are: |
| 230 |
@begin{itemize} |
| 231 |
the currency string; |
| 232 |
|
| 233 |
the digits group separator character; |
| 234 |
|
| 235 |
the radix mark character; and |
| 236 |
|
| 237 |
the fill character that replaces leading zeros of the numeric value. |
| 238 |
@end{itemize} |
| 239 |
|
| 240 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00285-01]} |
| 241 |
For Text_IO.Editing the edited output and currency strings are of |
| 242 |
type String, and the locale characters are of type Character. |
| 243 |
For Wide_@!Text_IO.@!Editing their types are Wide_@!String and Wide_@!Character, |
| 244 |
respectively.@Chg{Version=[2],New=[ For Wide_Wide_@!Text_IO.@!Editing |
| 245 |
their types are Wide_Wide_@!String and Wide_Wide_@!Character, respectively.],Old=[]} |
| 246 |
|
| 247 |
Each of the locale elements has a default value that can be replaced or |
| 248 |
explicitly overridden. |
| 249 |
|
| 250 |
A format-control |
| 251 |
value is of the private type Picture; it determines |
| 252 |
the composition of the edited output string and controls the form and |
| 253 |
placement of the sign, the position of the locale elements and the |
| 254 |
decimal digits, the presence or absence of a radix mark, suppression |
| 255 |
of leading zeros, and insertion of particular character values. |
| 256 |
|
| 257 |
@Leading@;A Picture object is composed from a String value, known as a |
| 258 |
@i{picture String}, that serves as a template for the |
| 259 |
edited output string, and a |
| 260 |
Boolean value that controls whether a string of all space characters is |
| 261 |
produced when the number's value is zero. A picture String comprises a |
| 262 |
sequence of one- or two-Character symbols, each serving as a placeholder |
| 263 |
for a character or string at a corresponding position in the edited |
| 264 |
output string. The picture String symbols fall into several categories |
| 265 |
based on their effect on the edited output string: |
| 266 |
@TabClear() |
| 267 |
@begin{Display} |
| 268 |
@TabSet{3, 21, 27, 33, 39, 45, 51} |
| 269 |
@\Decimal Digit: @\'9' |
| 270 |
@\Radix Control: @\'.' @\'V' |
| 271 |
@\Sign Control: @\'+' @\'@en@;' @\'<' @\'>' @\"CR" @\"DB" |
| 272 |
@\Currency Control: @\'$' @\'#' |
| 273 |
@\Zero Suppression: @\'Z' @\'*' |
| 274 |
@\Simple Insertion: @\'_' @\'B' @\'0' @\'/' |
| 275 |
@end{Display} |
| 276 |
|
| 277 |
The entries are not case-sensitive. Mixed- or lower-case forms |
| 278 |
for "CR" and "DB", and lower-case forms for 'V', 'Z', and 'B', |
| 279 |
have the same effect as the upper-case symbols shown. |
| 280 |
|
| 281 |
An occurrence of a '9' Character in the picture String represents a |
| 282 |
decimal digit position in the edited output string. |
| 283 |
|
| 284 |
A radix control Character in the picture String indicates the position |
| 285 |
of the radix mark in the edited output string: an actual character |
| 286 |
position for '.', or an assumed position for 'V'. |
| 287 |
|
| 288 |
A sign control Character in the picture String affects the form of the |
| 289 |
sign in the edited output string. The '<' and '>' Character values indicate |
| 290 |
parentheses for negative values. A Character '+', '@en@;', or '<' appears |
| 291 |
either singly, signifying a fixed-position sign in the edited output, |
| 292 |
or repeated, signifying a floating-position sign that is preceded by |
| 293 |
zero or more space characters and that replaces a leading 0. |
| 294 |
|
| 295 |
A currency control Character in the picture String indicates an |
| 296 |
occurrence of the currency string in the edited output string. The |
| 297 |
'$' Character represents the complete currency string; the '#' |
| 298 |
Character represents one character of the currency string. A '$' |
| 299 |
Character appears either singly, indicating a fixed-position currency |
| 300 |
string in the edited output, or repeated, indicating a |
| 301 |
floating-position currency string that occurs in place of a leading 0. |
| 302 |
A sequence of '#' Character values indicates either a fixed- or |
| 303 |
floating-position currency string, depending on context. |
| 304 |
|
| 305 |
A zero suppression Character in the picture String allows a leading |
| 306 |
zero to be replaced by either the space character (for 'Z') or |
| 307 |
the fill character (for '*'). |
| 308 |
|
| 309 |
A simple insertion Character in the picture String represents, in |
| 310 |
general, either itself (if '/' or '0'), the space character (if 'B'), |
| 311 |
or the digits group separator character (if '_'). In some contexts it |
| 312 |
is treated as part of a floating sign, floating currency, or zero |
| 313 |
suppression string. |
| 314 |
|
| 315 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00434-01]} |
| 316 |
An example of a picture String is "<###Z_ZZ9.99>". If the currency string |
| 317 |
is "@Chg{Version=[2],New=[kr],Old=[FF]}", the separator character is ',', and |
| 318 |
the radix mark is '.' then the edited output string values for the decimal |
| 319 |
values 32.10 and @en@;5432.10 are |
| 320 |
"bb@Chg{Version=[2],New=[kr],Old=[FF]}bbb32.10b" and |
| 321 |
"(b@Chg{Version=[2],New=[kr],Old=[FF]}5,432.10)", respectively, where 'b' |
| 322 |
indicates the space character. |
| 323 |
|
| 324 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00285-01]} |
| 325 |
The generic packages Text_IO.Decimal_IO@Chg{Version=[2],New=[,],Old=[ and]} |
| 326 |
Wide_Text_IO.Decimal_IO@Chg{Version=[2],New=[, and Wide_Wide_Text_IO.Decimal_IO],Old=[]} |
| 327 |
(see @RefSec(Input-Output for Real Types)) |
| 328 |
provide text input and nonedited text output for decimal types. |
| 329 |
@end{Intro} |
| 330 |
|
| 331 |
@begin{Notes} |
| 332 |
@ChgRef{Version=[2],Kind=[Revised],ARef=[AI95-00285-01]} |
| 333 |
A picture String is of type Standard.String, @Chg{Version=[2],New=[for all of], |
| 334 |
Old=[both for]} Text_IO.Editing@Chg{Version=[2],New=[,],Old=[ and]} |
| 335 |
Wide_Text_IO.Editing@Chg{Version=[2],New=[, and Wide_Wide_Text_IO.Editing],Old=[]}. |
| 336 |
@end{Notes} |
| 337 |
|
| 338 |
@begin{DiffWord95} |
| 339 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]} |
| 340 |
@ChgAdded{Version=[2],Text=[Added descriptions of Wide_Wide_Text_IO.Editing; |
| 341 |
see @RefSecNum{The Package Wide_Wide_Text_IO.Editing}.]} |
| 342 |
@end{DiffWord95} |
| 343 |
|
| 344 |
|
| 345 |
@LabeledSubClause{Picture String Formation} |
| 346 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0299-1]} |
| 347 |
@begin{Intro} |
| 348 |
@Defn2{term=[picture String],sec=[for edited output]} |
| 349 |
@Defn2{term=[well-formed picture String],sec=[for edited output]} |
| 350 |
A @i{well-formed picture String}, or simply @i{picture String}, |
| 351 |
is a String value that conforms to the |
| 352 |
syntactic rules, composition constraints, and character replication |
| 353 |
conventions specified in this @Chg{Version=[3],New=[subclause],Old=[clause]}. |
| 354 |
@end{Intro} |
| 355 |
|
| 356 |
@begin{RunTime} |
| 357 |
@TabClear() |
| 358 |
@ChgRef{Version=[1], Kind=[Deleted]} |
| 359 |
@Chg[New=<>,Old=<@ @;@comment{Empty paragraph to hang junk paragraph number from original RM}>] |
| 360 |
@begin{Display} |
| 361 |
@ntf{picture_string} ::= |
| 362 |
@ntf{fixed_$_picture_string} |
| 363 |
| @ntf{fixed_#_picture_string} |
| 364 |
| @ntf{floating_currency_picture_string} |
| 365 |
| @ntf{non_currency_picture_string} |
| 366 |
@comment{Blank Line} |
| 367 |
@end{Display} |
| 368 |
@begin{display} |
| 369 |
@ntf{fixed_$_picture_string} ::= |
| 370 |
[@ntf{fixed_LHS_sign}] @ntf{fixed_$_char} {@ntf{direct_insertion}} [@ntf{zero_suppression}] |
| 371 |
@ntf{number} [@ntf{RHS_sign}] |
| 372 |
@comment{Blank Line} |
| 373 |
| [@ntf{fixed_LHS_sign} {@ntf{direct_insertion}}] [@ntf{zero_suppression}] |
| 374 |
@ntf{number} @ntf{fixed_$_char} {@ntf{direct_insertion}} [@ntf{RHS_sign}] |
| 375 |
@comment{Blank Line} |
| 376 |
| @ntf{floating_LHS_sign} @ntf{number} @ntf{fixed_$_char} {@ntf{direct_insertion}} [@ntf{RHS_sign}] |
| 377 |
@comment{Blank Line} |
| 378 |
| [@ntf{fixed_LHS_sign}] @ntf{fixed_$_char} {@ntf{direct_insertion}} |
| 379 |
@ntf{all_zero_suppression_number} {@ntf{direct_insertion}} [@ntf{RHS_sign}] |
| 380 |
@comment{Blank Line} |
| 381 |
| [@ntf{fixed_LHS_sign} {@ntf{direct_insertion}}] @ntf{all_zero_suppression_number} {@ntf{direct_insertion}} |
| 382 |
@ntf{fixed_$_char} {@ntf{direct_insertion}} [@ntf{RHS_sign}] |
| 383 |
@comment{Blank Line} |
| 384 |
| @ntf{all_sign_number} {@ntf{direct_insertion}} @ntf{fixed_$_char} {@ntf{direct_insertion}} [@ntf{RHS_sign}] |
| 385 |
@comment{Blank Line} |
| 386 |
@end{display} |
| 387 |
@begin{display} |
| 388 |
@ntf{fixed_#_picture_string} ::= |
| 389 |
[@ntf{fixed_LHS_sign}] @ntf{single_#_currency} {@ntf{direct_insertion}} |
| 390 |
[@ntf{zero_suppression}] @ntf{number} [@ntf{RHS_sign}] |
| 391 |
@comment{Blank Line} |
| 392 |
| [@ntf{fixed_LHS_sign}] @ntf{multiple_#_currency} {@ntf{direct_insertion}} |
| 393 |
@ntf{zero_suppression} @ntf{number} [@ntf{RHS_sign}] |
| 394 |
@comment{Blank Line} |
| 395 |
| [@ntf{fixed_LHS_sign} {@ntf{direct_insertion}}] [@ntf{zero_suppression}] |
| 396 |
@ntf{number} @ntf{fixed_#_currency} {@ntf{direct_insertion}} [@ntf{RHS_sign}] |
| 397 |
@comment{Blank Line} |
| 398 |
| @ntf{floating_LHS_sign} @ntf{number} @ntf{fixed_#_currency} {@ntf{direct_insertion}} [@ntf{RHS_sign}] |
| 399 |
@comment{Blank Line} |
| 400 |
| [@ntf{fixed_LHS_sign}] @ntf{single_#_currency} {@ntf{direct_insertion}} |
| 401 |
@ntf{all_zero_suppression_number} {@ntf{direct_insertion}} [@ntf{RHS_sign}] |
| 402 |
@comment{Blank Line} |
| 403 |
| [@ntf{fixed_LHS_sign}] @ntf{multiple_#_currency} {@ntf{direct_insertion}} |
| 404 |
@ntf{all_zero_suppression_number} {@ntf{direct_insertion}} [@ntf{RHS_sign}] |
| 405 |
@comment{Blank Line} |
| 406 |
| [@ntf{fixed_LHS_sign} {@ntf{direct_insertion}}] @ntf{all_zero_suppression_number} {@ntf{direct_insertion}} |
| 407 |
@ntf{fixed_#_currency} {@ntf{direct_insertion}} [@ntf{RHS_sign}] |
| 408 |
@comment{Blank Line} |
| 409 |
| @ntf{all_sign_number} {@ntf{direct_insertion}} @ntf{fixed_#_currency} {@ntf{direct_insertion}} [@ntf{RHS_sign}] |
| 410 |
@comment{Blank Line} |
| 411 |
@end{display} |
| 412 |
@begin{display} |
| 413 |
@ntf{floating_currency_picture_string} ::= |
| 414 |
[@ntf{fixed_LHS_sign}] {@ntf{direct_insertion}} @ntf{floating_$_currency} @ntf{number} [@ntf{RHS_sign}] |
| 415 |
| [@ntf{fixed_LHS_sign}] {@ntf{direct_insertion}} @ntf{floating_#_currency} @ntf{number} [@ntf{RHS_sign}] |
| 416 |
| [@ntf{fixed_LHS_sign}] {@ntf{direct_insertion}} @ntf{all_currency_number} {@ntf{direct_insertion}} [@ntf{RHS_sign}] |
| 417 |
@comment{Blank Line} |
| 418 |
@end{display} |
| 419 |
@begin{display} |
| 420 |
@ntf{non_currency_picture_string} ::= |
| 421 |
[@ntf{fixed_LHS_sign} {@ntf{direct_insertion}}] @ntf{zero_suppression} @ntf{number} [@ntf{RHS_sign}] |
| 422 |
| [@ntf{floating_LHS_sign}] @ntf{number} [@ntf{RHS_sign}] |
| 423 |
| [@ntf{fixed_LHS_sign} {@ntf{direct_insertion}}] @ntf{all_zero_suppression_number} {@ntf{direct_insertion}} |
| 424 |
[@ntf{RHS_sign}] |
| 425 |
| @ntf{all_sign_number} {@ntf{direct_insertion}} |
| 426 |
| @ntf{fixed_LHS_sign} @ntf{direct_insertion} {@ntf{direct_insertion}} @ntf{number} [@ntf{RHS_sign}] |
| 427 |
@comment{Blank Line} |
| 428 |
@end{display} |
| 429 |
@begin{display} |
| 430 |
@ntf{fixed_LHS_sign} ::= @ntf{LHS_Sign} |
| 431 |
@end{display} |
| 432 |
@begin{display} |
| 433 |
@ntf{LHS_Sign} ::= + | @en | < |
| 434 |
@comment{Blank Line} |
| 435 |
@end{display} |
| 436 |
@begin{display} |
| 437 |
@ntf{fixed_$_char} ::= $ |
| 438 |
@comment{Blank Line} |
| 439 |
@end{display} |
| 440 |
@begin{display} |
| 441 |
@ntf{direct_insertion} ::= @ntf{simple_insertion} |
| 442 |
@end{display} |
| 443 |
@begin{display} |
| 444 |
@ntf{simple_insertion} ::= _ | B | 0 | / |
| 445 |
@comment{Blank Line} |
| 446 |
@end{display} |
| 447 |
@begin{display} |
| 448 |
@ntf{zero_suppression} ::= Z {Z | @ntf{context_sensitive_insertion}} | @ntf{fill_string} |
| 449 |
@end{display} |
| 450 |
@begin{display} |
| 451 |
@ntf{context_sensitive_insertion} ::= @ntf{simple_insertion} |
| 452 |
@comment{Blank Line} |
| 453 |
@end{display} |
| 454 |
@begin{display} |
| 455 |
@ntf{fill_string} ::= * {* | @ntf{context_sensitive_insertion}} |
| 456 |
@comment{Blank Line} |
| 457 |
@end{display} |
| 458 |
@begin{display} |
| 459 |
@ntf{number} ::= |
| 460 |
@ntf{fore_digits} [@ntf{radix} [@ntf{aft_digits}] {@ntf{direct_insertion}}] |
| 461 |
| @ntf{radix} @ntf{aft_digits} {@ntf{direct_insertion}} |
| 462 |
@end{display} |
| 463 |
@begin{display} |
| 464 |
@ntf{fore_digits} ::= 9 {9 | @ntf{direct_insertion}} |
| 465 |
@end{display} |
| 466 |
@begin{display} |
| 467 |
@ntf{aft_digits} ::= {9 | @ntf{direct_insertion}} 9 |
| 468 |
@end{display} |
| 469 |
@begin{display} |
| 470 |
@ntf{radix} ::= . | V |
| 471 |
@comment{Blank Line} |
| 472 |
@end{display} |
| 473 |
@begin{display} |
| 474 |
@ntf{RHS_sign} ::= + | @en | > | CR | DB |
| 475 |
@comment{Blank Line} |
| 476 |
@end{display} |
| 477 |
@begin{display} |
| 478 |
@ntf{floating_LHS_sign} ::= |
| 479 |
@ntf{LHS_Sign} {@ntf{context_sensitive_insertion}} @ntf{LHS_Sign} {@ntf{LHS_Sign} | @ntf{context_sensitive_insertion}} |
| 480 |
@comment{Blank Line} |
| 481 |
@end{display} |
| 482 |
@begin{display} |
| 483 |
@ntf{single_#_currency} ::= # |
| 484 |
@end{display} |
| 485 |
@begin{display} |
| 486 |
@ntf{multiple_#_currency} ::= ## {#} |
| 487 |
@comment{Blank Line} |
| 488 |
@end{display} |
| 489 |
@begin{display} |
| 490 |
@ntf{fixed_#_currency} ::= @ntf{single_#_currency} | @ntf{multiple_#_currency} |
| 491 |
@comment{Blank Line} |
| 492 |
@end{display} |
| 493 |
@begin{display} |
| 494 |
@ntf{floating_$_currency} ::= |
| 495 |
$ {@ntf{context_sensitive_insertion}} $ {$ | @ntf{context_sensitive_insertion}} |
| 496 |
@comment{Blank Line} |
| 497 |
@end{display} |
| 498 |
@begin{display} |
| 499 |
@ntf{floating_#_currency} ::= |
| 500 |
# {@ntf{context_sensitive_insertion}} # {# | @ntf{context_sensitive_insertion}} |
| 501 |
@comment{Blank Line} |
| 502 |
@end{display} |
| 503 |
@begin{display} |
| 504 |
@ntf{all_sign_number} ::= @ntf{all_sign_fore} [@ntf{radix} [@ntf{all_sign_aft}]] [>] |
| 505 |
@end{display} |
| 506 |
@begin{display} |
| 507 |
@ntf{all_sign_fore} ::= |
| 508 |
@ntf{sign_char} {@ntf{context_sensitive_insertion}} @ntf{sign_char} {@ntf{sign_char} | @ntf{context_sensitive_insertion}} |
| 509 |
@end{display} |
| 510 |
@begin{display} |
| 511 |
@ntf{all_sign_aft} ::= {@ntf{all_sign_aft_char}} @ntf{sign_char} |
| 512 |
@comment{Blank Line} |
| 513 |
@ntf{all_sign_aft_char} ::= @ntf{sign_char} | @ntf{context_sensitive_insertion} |
| 514 |
@end{display} |
| 515 |
@begin{display} |
| 516 |
@ntf{sign_char} ::= + | @en | < |
| 517 |
@comment{Blank Line} |
| 518 |
@end{display} |
| 519 |
@begin{display} |
| 520 |
@ntf{all_currency_number} ::= @ntf{all_currency_fore} [@ntf{radix} [@ntf{all_currency_aft}]] |
| 521 |
@end{display} |
| 522 |
@begin{display} |
| 523 |
@ntf{all_currency_fore} ::= |
| 524 |
@ntf{currency_char} {@ntf{context_sensitive_insertion}} |
| 525 |
@ntf{currency_char} {@ntf{currency_char} | @ntf{context_sensitive_insertion}} |
| 526 |
@end{display} |
| 527 |
@begin{display} |
| 528 |
@ntf{all_currency_aft} ::= {@ntf{all_currency_aft_char}} @ntf{currency_char} |
| 529 |
@comment{Blank Line} |
| 530 |
@ntf{all_currency_aft_char} ::= @ntf{currency_char} | @ntf{context_sensitive_insertion} |
| 531 |
@end{display} |
| 532 |
@begin{display} |
| 533 |
@ntf{currency_char} ::= $ | # |
| 534 |
@comment{Blank Line} |
| 535 |
@end{display} |
| 536 |
@begin{display} |
| 537 |
@ntf{all_zero_suppression_number} ::= @ntf{all_zero_suppression_fore} [ @ntf{radix} [@ntf{all_zero_suppression_aft}]] |
| 538 |
@end{display} |
| 539 |
@begin{display} |
| 540 |
@ntf{all_zero_suppression_fore} ::= |
| 541 |
@ntf{zero_suppression_char} {@ntf{zero_suppression_char} | @ntf{context_sensitive_insertion}} |
| 542 |
@end{display} |
| 543 |
@begin{display} |
| 544 |
@ntf{all_zero_suppression_aft} ::= {@ntf{all_zero_suppression_aft_char}} @ntf{zero_suppression_char} |
| 545 |
@comment{Blank Line} |
| 546 |
@ntf{all_zero_suppression_aft_char} ::= @ntf{zero_suppression_char} | @ntf{context_sensitive_insertion} |
| 547 |
@end{display} |
| 548 |
@begin{display} |
| 549 |
@trailing@ntf{zero_suppression_char} ::= Z | * |
| 550 |
@end{Display} |
| 551 |
|
| 552 |
@Leading@;The following composition constraints apply to a picture String: |
| 553 |
@begin{Itemize} |
| 554 |
A @ntf{floating_LHS_sign} does not have occurrences of different @ntf{LHS_Sign} |
| 555 |
Character values. |
| 556 |
|
| 557 |
If a picture String has '<' as @ntf{fixed_LHS_sign}, then it has '>' as |
| 558 |
@ntf{RHS_sign}. |
| 559 |
|
| 560 |
If a picture String has '<' in a @ntf{floating_LHS_sign} or in an |
| 561 |
@ntf{all_sign_number}, then it has an occurrence of '>'. |
| 562 |
|
| 563 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0088],ARef=[AI95-00153]} |
| 564 |
If a picture String has '+' or '@en@;' as @ntf{fixed_LHS_sign}, in a |
| 565 |
@ntf{floating_LHS_sign}, or in an @ntf{all_sign_number}, then it has no |
| 566 |
@ntf{RHS_sign}@Chg{New=[ or '>' character],Old=[]}. |
| 567 |
|
| 568 |
An instance of @ntf{all_sign_number} does not have occurrences of |
| 569 |
different @ntf{sign_char} Character values. |
| 570 |
|
| 571 |
An instance of @ntf{all_currency_number} does not have occurrences of |
| 572 |
different @ntf{currency_@!char} Character values. |
| 573 |
|
| 574 |
An instance of @ntf{all_zero_suppression_number} does not have occurrences |
| 575 |
of different @ntf{zero_@!suppression_@!char} Character values, except for possible |
| 576 |
case differences between 'Z' and 'z'. |
| 577 |
@end{Itemize} |
| 578 |
|
| 579 |
A @i{replicable Character} is a Character that, by the |
| 580 |
above rules, can occur in two consecutive positions in a picture String. |
| 581 |
|
| 582 |
@Leading@;A @i{Character replication} is a String |
| 583 |
@begin{example} |
| 584 |
@RI{char} & '(' & @RI{spaces} & @RI{count_string} & ')' |
| 585 |
@end{example} |
| 586 |
where @i{char} is a replicable Character, |
| 587 |
@i{spaces} is a String (possibly empty) comprising only space Character values, |
| 588 |
and @i{count_string} is a String of one or more decimal digit Character |
| 589 |
values. A Character replication in a picture String has the same effect |
| 590 |
as (and is said to be @i{equivalent to}) a String comprising @i[n] |
| 591 |
consecutive occurrences of @i{char}, where |
| 592 |
@i[n]=Integer'Value(@i{count_string}). |
| 593 |
|
| 594 |
An @i{expanded picture String} is a picture String containing no |
| 595 |
Character replications. |
| 596 |
@begin{Discussion} |
| 597 |
|
| 598 |
Since 'B' is not allowed after a RHS sign, there is no need |
| 599 |
for a special rule to disallow "9.99DB(2)" as an abbreviation for |
| 600 |
"9.99DBB" |
| 601 |
@end{discussion} |
| 602 |
@end{RunTime} |
| 603 |
|
| 604 |
@begin{Notes} |
| 605 |
Although a sign to the left of the number can float, a sign to the right |
| 606 |
of the number is in a fixed position. |
| 607 |
@end{Notes} |
| 608 |
|
| 609 |
@begin{DiffWord95} |
| 610 |
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0088],ARef=[AI95-00153-01]} |
| 611 |
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> The picture string rules for |
| 612 |
numbers were tightened.]} |
| 613 |
@end{DiffWord95} |
| 614 |
|
| 615 |
|
| 616 |
@LabeledSubClause{Edited Output Generation} |
| 617 |
@begin{RunTime} |
| 618 |
@Leading@;The contents of an edited output string are based on: |
| 619 |
@begin{Itemize} |
| 620 |
A value, Item, of some decimal type Num, |
| 621 |
|
| 622 |
An expanded picture String Pic_String, |
| 623 |
|
| 624 |
A Boolean value, Blank_When_Zero, |
| 625 |
|
| 626 |
A Currency string, |
| 627 |
|
| 628 |
A Fill character, |
| 629 |
|
| 630 |
A Separator character, and |
| 631 |
|
| 632 |
A Radix_Mark character. |
| 633 |
@end{Itemize} |
| 634 |
|
| 635 |
The combination of a True value for Blank_When_Zero and a '*' character |
| 636 |
in Pic_String is inconsistent; no edited output string is defined. |
| 637 |
@begin{Reason} |
| 638 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00114-01]} |
| 639 |
@ChgAdded{Version=[2],Text=[Such a Pic_String is invalid, and any attempt |
| 640 |
to use such a string will raise Picture_Error.]} |
| 641 |
@end{Reason} |
| 642 |
|
| 643 |
|
| 644 |
A layout error is identified in the rules below if leading |
| 645 |
nonzero digits of Item, character values of the Currency string, |
| 646 |
or a negative sign would be |
| 647 |
truncated; in such cases no edited output string is defined. |
| 648 |
|
| 649 |
The edited output string has lower bound 1 and upper bound N where |
| 650 |
N = Pic_String'Length + Currency_Length_Adjustment @en |
| 651 |
Radix_Adjustment, and |
| 652 |
@begin{Itemize} |
| 653 |
Currency_Length_Adjustment = |
| 654 |
Currency'Length @en@; 1 if there is some occurrence of '$' in |
| 655 |
Pic_String, and |
| 656 |
0 otherwise. |
| 657 |
|
| 658 |
Radix_Adjustment = |
| 659 |
1 if there is an occurrence of 'V' or 'v' in Pic_Str, and |
| 660 |
0 otherwise. |
| 661 |
@end{Itemize} |
| 662 |
|
| 663 |
@Leading@defn{displayed magnitude (of a decimal value)} |
| 664 |
Let the magnitude of Item be expressed as a base-10 number |
| 665 |
I@-(p)@Times@Times@Times@;I@-(1).F@-(1)@Times@Times@Times@;F@-(q), |
| 666 |
called the @i{displayed} @i{magnitude} of Item, |
| 667 |
where: |
| 668 |
@begin{Itemize} |
| 669 |
q = Min(Max(Num'Scale, 0), n) where n is 0 if Pic_String |
| 670 |
has no @ntf{radix} and is otherwise the number of digit |
| 671 |
positions following @ntf{radix} in Pic_String, |
| 672 |
where a digit position corresponds to an occurrence of |
| 673 |
'9', a @ntf{zero_suppression_char} (for an |
| 674 |
@ntf{all_zero_suppression_number}), a @ntf{currency_char} |
| 675 |
(for an @ntf{all_currency_number}), or a @ntf{sign_char} |
| 676 |
(for an @ntf{all_sign_number}). |
| 677 |
|
| 678 |
I@-(p) /= 0 if p>0. |
| 679 |
@end{Itemize} |
| 680 |
|
| 681 |
If n < Num'Scale, then the above number is the result of rounding |
| 682 |
(away from 0 if exactly midway between values). |
| 683 |
|
| 684 |
If Blank_When_Zero = True and the displayed magnitude of Item |
| 685 |
is zero, |
| 686 |
then the edited output string |
| 687 |
comprises all space character values. Otherwise, the picture String is |
| 688 |
treated as a sequence of instances of syntactic categories based on |
| 689 |
the rules in @RefSecNum[Picture String Formation], |
| 690 |
and the edited output string is the concatenation of |
| 691 |
string values derived from these categories according to the |
| 692 |
following mapping rules. |
| 693 |
|
| 694 |
Table F-1 shows the mapping from a sign control symbol to a |
| 695 |
corresponding character or string in the edited output. In the |
| 696 |
columns showing the edited output, a lower-case 'b' represents the |
| 697 |
space character. |
| 698 |
If there is no sign control symbol but the value of Item |
| 699 |
is negative, a layout error occurs and no edited output string |
| 700 |
is produced. |
| 701 |
|
| 702 |
@Table{Columns=<3>,Alignment=<AllCenter>,FirstColWidth=[1],LastColWidth=[1], |
| 703 |
NoBreak=[T],Border=[T],SmallSize=[F], |
| 704 |
Caption=<@b{Table F-1: Edited Output for Sign Control Symbols}>, |
| 705 |
Headers=<@b{Sign Control Symbol}@\@b{Edited Output for @*Nonnegative Number}@\@b{Edited Output for @*Negative Number}>, |
| 706 |
Body=['+'@\'+'@\'@en@;' |
| 707 |
'@en@;'@\'b'@\'@en@;' |
| 708 |
'<'@\'b'@\'(' |
| 709 |
'>'@\'b'@\')' |
| 710 |
"CR"@\"bb"@\"CR"@Last |
| 711 |
"DB"@\"bb"@\"DB"]} |
| 712 |
|
| 713 |
An instance of @ntf{fixed_LHS_sign} maps to a character as shown in |
| 714 |
Table F-1. |
| 715 |
|
| 716 |
An instance of @ntf{fixed_$_char} maps to Currency. |
| 717 |
|
| 718 |
An instance of @ntf{direct_insertion} maps to |
| 719 |
Separator if @ntf{direct_insertion} = '_', and to |
| 720 |
the @ntf{direct_insertion} Character otherwise. |
| 721 |
|
| 722 |
|
| 723 |
@Leading@;An instance of @ntf{number} maps to a string |
| 724 |
@i{integer_part} & @i{radix_part} & @i{fraction_part} |
| 725 |
where: |
| 726 |
@begin{Itemize} |
| 727 |
The string for @i{integer_part} is obtained as follows: |
| 728 |
@begin{Enumerate} |
| 729 |
Occurrences of '9' in @ntf{fore_digits} of @ntf{number} are replaced |
| 730 |
from right to left with the decimal digit character values for |
| 731 |
I@-(1), ..., I@-(p), respectively. |
| 732 |
|
| 733 |
Each occurrence of '9' in @ntf{fore_digits} |
| 734 |
to the left of the leftmost '9' replaced according |
| 735 |
to rule 1 is replaced with '0'. |
| 736 |
|
| 737 |
If p exceeds the number of occurrences of '9' in |
| 738 |
@ntf{fore_digits} of @ntf{number}, then the excess leftmost |
| 739 |
digits are eligible for use in the mapping of |
| 740 |
an instance of @ntf{zero_suppression}, @ntf{floating_LHS_sign}, |
| 741 |
@ntf{floating_$_currency}, |
| 742 |
or @ntf{floating_#_currency} to the left of @ntf{number}; |
| 743 |
if there is no such instance, then a layout error |
| 744 |
occurs and no edited output string is produced. |
| 745 |
@end{Enumerate} |
| 746 |
|
| 747 |
@leading@;The @i{radix_part} is: |
| 748 |
@begin{InnerItemize} |
| 749 |
"" if @ntf{number} does not include a @ntf{radix}, if @ntf{radix} = 'V', |
| 750 |
or if @ntf{radix} = 'v' |
| 751 |
|
| 752 |
Radix_Mark if @ntf{number} includes '.' as @ntf{radix} |
| 753 |
@end{InnerItemize} |
| 754 |
|
| 755 |
@leading@;The string for @i{fraction_part} is obtained as follows: |
| 756 |
@begin{Enumerate} |
| 757 |
Occurrences of '9' |
| 758 |
in @ntf{aft_digits} of @ntf{number} are replaced |
| 759 |
from left to right with the decimal digit character values for F@-(1), |
| 760 |
... F@-(q). |
| 761 |
|
| 762 |
Each occurrence of '9' in @ntf{aft_digits} |
| 763 |
to the right of the rightmost '9' replaced according to rule 1 |
| 764 |
is replaced by '0'. |
| 765 |
@end{Enumerate} |
| 766 |
@end{Itemize} |
| 767 |
|
| 768 |
@leading@;An instance of @ntf{zero_suppression} maps to the string obtained as follows: |
| 769 |
@begin{Enumerate} |
| 770 |
The rightmost 'Z', 'z', or '*' Character values |
| 771 |
are replaced |
| 772 |
with the excess digits (if any) |
| 773 |
from the @i{integer_part} of the mapping of the @ntf{number} |
| 774 |
to the right of the @ntf{zero_suppression} instance, |
| 775 |
|
| 776 |
A @ntf{context_sensitive_insertion} Character is replaced |
| 777 |
as though it were a @ntf{direct_insertion} Character, if |
| 778 |
it occurs to the right of some 'Z', 'z', or '*' in |
| 779 |
@ntf{zero_suppression} that has been mapped to an excess |
| 780 |
digit, |
| 781 |
|
| 782 |
@leading@;Each Character to the left of the |
| 783 |
leftmost Character replaced according to rule 1 above |
| 784 |
is replaced by: |
| 785 |
@begin{InnerItemize} |
| 786 |
the space character if the zero suppression Character is |
| 787 |
'Z' or 'z', or |
| 788 |
|
| 789 |
the Fill character if the zero suppression Character is '*'. |
| 790 |
@end{InnerItemize} |
| 791 |
|
| 792 |
A layout error occurs if some excess digits remain |
| 793 |
after all 'Z', 'z', and '*' Character values in |
| 794 |
@ntf{zero_suppression} have been replaced via rule 1; no |
| 795 |
edited output string is produced. |
| 796 |
@end{Enumerate} |
| 797 |
|
| 798 |
An instance of @ntf{RHS_sign} maps to a character or string |
| 799 |
as shown in Table F-1. |
| 800 |
|
| 801 |
|
| 802 |
An instance of @ntf{floating_LHS_sign} maps to the string obtained as follows. |
| 803 |
@begin{Enumerate} |
| 804 |
Up to all but one of the rightmost @ntf{LHS_Sign} |
| 805 |
Character values are replaced by the excess digits (if any) |
| 806 |
from the @i{integer_part} of the mapping of the @ntf{number} |
| 807 |
to the right of the @ntf{floating_LHS_sign} instance. |
| 808 |
|
| 809 |
The next Character to the left is replaced |
| 810 |
with the character given by the entry in Table F-1 |
| 811 |
corresponding to the @ntf{LHS_Sign} Character. |
| 812 |
|
| 813 |
A @ntf{context_sensitive_insertion} Character is replaced |
| 814 |
as though it were a @ntf{direct_insertion} Character, if |
| 815 |
it occurs to the right of the leftmost @ntf{LHS_Sign} |
| 816 |
character replaced according to rule 1. |
| 817 |
|
| 818 |
Any other Character is replaced by the space character.. |
| 819 |
|
| 820 |
A layout error occurs if some excess digits remain |
| 821 |
after replacement via rule 1; no edited output string is |
| 822 |
produced. |
| 823 |
@end{Enumerate} |
| 824 |
|
| 825 |
An instance of @ntf{fixed_#_currency} maps to the Currency string with n |
| 826 |
space character values concatenated on the left (if the instance does |
| 827 |
not follow a @ntf{radix}) or on the right (if the instance does follow a |
| 828 |
@ntf{radix}), where n is the difference between the length of the |
| 829 |
@ntf{fixed_#_currency} instance and Currency'Length. A layout error |
| 830 |
occurs if Currency'Length exceeds the length of the |
| 831 |
@ntf{fixed_#_currency} instance; no edited output string is produced. |
| 832 |
|
| 833 |
|
| 834 |
@Leading@;An instance of @ntf{floating_$_currency} maps to the string |
| 835 |
obtained as follows: |
| 836 |
@begin{Enumerate} |
| 837 |
Up to all but one of the rightmost '$' |
| 838 |
Character values are replaced |
| 839 |
with the excess digits (if any) |
| 840 |
from the @i{integer_part} of the mapping of the @ntf{number} |
| 841 |
to the right of the @ntf{floating_$_currency} instance. |
| 842 |
|
| 843 |
The next Character to the left is replaced |
| 844 |
by the Currency string. |
| 845 |
|
| 846 |
A @ntf{context_sensitive_insertion} Character is replaced |
| 847 |
as though it were a @ntf{direct_insertion} Character, if |
| 848 |
it occurs to the right of the leftmost '$' Character |
| 849 |
replaced via rule 1. |
| 850 |
|
| 851 |
Each other Character is replaced by the space character. |
| 852 |
|
| 853 |
A layout error occurs if some excess digits remain |
| 854 |
after replacement by rule 1; no edited output string is |
| 855 |
produced. |
| 856 |
@end{Enumerate} |
| 857 |
|
| 858 |
@leading@;An instance of @ntf{floating_#_currency} maps to the string obtained |
| 859 |
as follows: |
| 860 |
@begin{Enumerate} |
| 861 |
Up to all but one of the rightmost '#' |
| 862 |
Character values are replaced |
| 863 |
with the excess digits (if any) |
| 864 |
from the @i{integer_part} of the mapping of the @ntf{number} |
| 865 |
to the right of the |
| 866 |
@ntf{floating_#_currency} instance. |
| 867 |
|
| 868 |
The substring whose last Character occurs at the position immediately |
| 869 |
preceding the leftmost Character replaced via rule 1, and whose |
| 870 |
length is Currency'Length, is replaced by the Currency string. |
| 871 |
|
| 872 |
A @ntf{context_sensitive_insertion} Character is replaced |
| 873 |
as though it were a @ntf{direct_insertion} Character, if |
| 874 |
it occurs to the right of the leftmost '#' |
| 875 |
replaced via rule 1. |
| 876 |
|
| 877 |
Any other Character is replaced by the space character. |
| 878 |
|
| 879 |
A layout error occurs if some excess digits remain |
| 880 |
after replacement rule 1, or if there is no substring |
| 881 |
with the required length for replacement rule 2; no edited |
| 882 |
output string is produced. |
| 883 |
@end{Enumerate} |
| 884 |
|
| 885 |
@leading@;An instance of @ntf{all_zero_suppression_number} maps to: |
| 886 |
@begin{Itemize} |
| 887 |
a string of all spaces if |
| 888 |
the displayed magnitude of Item is zero, |
| 889 |
the @ntf{zero_suppression_char} |
| 890 |
is 'Z' or 'z', and the instance of |
| 891 |
@ntf{all_zero_suppression_number} does not have |
| 892 |
a @ntf{radix} at its last character position; |
| 893 |
|
| 894 |
a string containing the Fill character in each position except |
| 895 |
for the character (if any) corresponding to @ntf{radix}, if |
| 896 |
@ntf{zero_suppression_char} = '*' and the |
| 897 |
displayed magnitude of Item is zero; |
| 898 |
|
| 899 |
otherwise, |
| 900 |
the same result as if each @ntf{zero_suppression_char} in |
| 901 |
@ntf{all_zero_suppression_aft} were '9', interpreting |
| 902 |
the instance of @ntf{all_zero_suppression_number} as |
| 903 |
either @ntf{zero_suppression} @ntf{number} (if a @ntf{radix} |
| 904 |
and @ntf{all_zero_suppression_aft} are present), or |
| 905 |
as @ntf{zero_suppression} otherwise. |
| 906 |
@end{Itemize} |
| 907 |
|
| 908 |
@leading@;An instance of @ntf{all_sign_number} maps to: |
| 909 |
@begin{Itemize} |
| 910 |
a string of all spaces if |
| 911 |
the displayed magnitude of Item is zero and the |
| 912 |
instance of @ntf{all_sign_number} does not have a @ntf{radix} |
| 913 |
at its last character position; |
| 914 |
|
| 915 |
otherwise, |
| 916 |
the same result as if each @ntf{sign_char} in |
| 917 |
@ntf{all_sign_number_aft} were '9', interpreting |
| 918 |
the instance of @ntf{all_sign_number} as |
| 919 |
either @ntf{floating_LHS_sign} @ntf{number} (if a @ntf{radix} |
| 920 |
and @ntf{all_sign_number_aft} are present), or |
| 921 |
as @ntf{floating_LHS_sign} otherwise. |
| 922 |
@end{Itemize} |
| 923 |
|
| 924 |
@leading@;An instance of @ntf{all_currency_number} maps to: |
| 925 |
@begin{Itemize} |
| 926 |
a string of all spaces if |
| 927 |
the displayed magnitude of Item is zero and the |
| 928 |
instance of @ntf{all_currency_number} does not have a @ntf{radix} |
| 929 |
at its last character position; |
| 930 |
|
| 931 |
otherwise, |
| 932 |
the same result as if each @ntf{currency_char} in |
| 933 |
@ntf{all_currency_number_aft} were '9', interpreting |
| 934 |
the instance of @ntf{all_currency_number} as |
| 935 |
@ntf{floating_$_currency} @ntf{number} or |
| 936 |
@ntf{floating_#_currency} @ntf{number} |
| 937 |
(if a @ntf{radix} |
| 938 |
and @ntf{all_currency_number_aft} are present), or |
| 939 |
as @ntf{floating_$_currency} or @ntf{floating_#_currency} |
| 940 |
otherwise. |
| 941 |
@end{Itemize} |
| 942 |
@end{RunTime} |
| 943 |
|
| 944 |
@begin{Examples} |
| 945 |
In the result string values shown below, 'b' represents the space character. |
| 946 |
@begin{Example} |
| 947 |
Item: Picture and Result Strings: |
| 948 |
|
| 949 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0248-1]} |
| 950 |
123456.78 Picture: "-###**_***_**9.99" |
| 951 |
@Chg{New=[Result:],Old=[ ]} "bbb$***123,456.78" |
| 952 |
"bbFF***123.456,78" (currency = "FF", |
| 953 |
separator = '.', |
| 954 |
radix mark = ',') |
| 955 |
|
| 956 |
@ChgRef{Version=[1],Kind=[Revised],Ref=[8652/0089],ARef=[AI95-00070]} |
| 957 |
123456.78 Picture: "-@Chg{New=[],Old=[$$]}$**_***_**9.99" |
| 958 |
Result: "@Chg{New=[],Old=[bb]}b$***123,456.78" |
| 959 |
"b@Chg{New=[],Old=[bb]}FF***123.456,78" (currency = "FF", |
| 960 |
@Chg{New=[],Old=[ ]} separator = '.', |
| 961 |
@Chg{New=[],Old=[ ]} radix mark = ',') |
| 962 |
|
| 963 |
0.0 Picture: "-$$$$$$.$$" |
| 964 |
Result: "bbbbbbbbbb" |
| 965 |
|
| 966 |
0.20 Picture: "-$$$$$$.$$" |
| 967 |
Result: "bbbbbb$.20" |
| 968 |
|
| 969 |
-1234.565 Picture: "<<<<_<<<.<<###>" |
| 970 |
Result: "bb(1,234.57DMb)" (currency = "DM") |
| 971 |
|
| 972 |
12345.67 Picture: "###_###_##9.99" |
| 973 |
Result: "bbCHF12,345.67" (currency = "CHF") |
| 974 |
@end{Example} |
| 975 |
@end{Examples} |
| 976 |
|
| 977 |
@begin{DiffWord95} |
| 978 |
@ChgRef{Version=[2],Kind=[AddedNormal],Ref=[8652/0089],ARef=[AI95-00070-01]} |
| 979 |
@ChgAdded{Version=[2],Text=[@b<Corrigendum:> Corrected the picture string |
| 980 |
example.]} |
| 981 |
@end{DiffWord95} |
| 982 |
|
| 983 |
|
| 984 |
@LabeledSubClause{The Package Text_IO.Editing} |
| 985 |
@begin{Intro} |
| 986 |
The package Text_IO.Editing provides a private type Picture with associated |
| 987 |
operations, and a generic package Decimal_Output. |
| 988 |
An object of type Picture is composed from a well-formed picture String |
| 989 |
(see @RefSecNum(Picture String Formation)) and a Boolean item indicating |
| 990 |
whether a zero numeric value will result in an edited output string |
| 991 |
of all space characters. |
| 992 |
The package Decimal_Output |
| 993 |
contains edited output subprograms implementing the effects defined |
| 994 |
in @RefSecNum(Edited Output Generation). |
| 995 |
@end{Intro} |
| 996 |
|
| 997 |
@begin{StaticSem} |
| 998 |
@leading@;The library package Text_IO.Editing has the following declaration: |
| 999 |
@begin{Example} |
| 1000 |
@ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0241-1]} |
| 1001 |
@key(package) Ada.Text_IO.Editing@Chg{Version=[5],New=[ |
| 1002 |
@key(with) Nonblocking],Old=[]} @key(is)@ChildUnit{Parent=[Ada.Text_IO],Child=[Editing]} |
| 1003 |
|
| 1004 |
@key(type) @AdaTypeDefn{Picture} @key(is) @key(private); |
| 1005 |
|
| 1006 |
@key(function) @AdaSubDefn{Valid} (Pic_String : @key(in) String; |
| 1007 |
Blank_When_Zero : @key(in) Boolean := False) @key(return) Boolean; |
| 1008 |
|
| 1009 |
@key(function) @AdaSubDefn{To_Picture} (Pic_String : @key(in) String; |
| 1010 |
Blank_When_Zero : @key(in) Boolean := False) |
| 1011 |
@key(return) Picture; |
| 1012 |
|
| 1013 |
@key(function) @AdaSubDefn{Pic_String} (Pic : @key(in) Picture) @key(return) String; |
| 1014 |
@key(function) @AdaSubDefn{Blank_When_Zero} (Pic : @key(in) Picture) @key(return) Boolean; |
| 1015 |
|
| 1016 |
@AdaObjDefn{Max_Picture_Length} : @key(constant) := @RI{implementation_defined}; |
| 1017 |
|
| 1018 |
@AdaExcDefn{Picture_Error} : @key(exception); |
| 1019 |
|
| 1020 |
@AdaObjDefn{Default_Currency} : @key(constant) String := "$"; |
| 1021 |
@AdaObjDefn{Default_Fill} : @key(constant) Character := '*'; |
| 1022 |
@AdaObjDefn{Default_Separator} : @key(constant) Character := ','; |
| 1023 |
@AdaObjDefn{Default_Radix_Mark} : @key(constant) Character := '.'; |
| 1024 |
|
| 1025 |
@key(generic) |
| 1026 |
@key(type) Num @key(is) @key(delta) <> @key(digits) <>; |
| 1027 |
Default_Currency : @key(in) String := Text_IO.Editing.Default_Currency; |
| 1028 |
Default_Fill : @key(in) Character := Text_IO.Editing.Default_Fill; |
| 1029 |
Default_Separator : @key(in) Character := |
| 1030 |
Text_IO.Editing.Default_Separator; |
| 1031 |
Default_Radix_Mark : @key(in) Character := |
| 1032 |
Text_IO.Editing.Default_Radix_Mark; |
| 1033 |
@key(package) @AdaPackDefn{Decimal_Output} @key(is) |
| 1034 |
@key(function) @AdaSubDefn{Length} (Pic : @key(in) Picture; |
| 1035 |
Currency : @key(in) String := Default_Currency) |
| 1036 |
@key(return) Natural; |
| 1037 |
|
| 1038 |
@key(function) @AdaSubDefn{Valid} (Item : @key(in) Num; |
| 1039 |
Pic : @key(in) Picture; |
| 1040 |
Currency : @key(in) String := Default_Currency) |
| 1041 |
@key(return) Boolean; |
| 1042 |
|
| 1043 |
@key(function) @AdaSubDefn{Image} (Item : @key(in) Num; |
| 1044 |
Pic : @key(in) Picture; |
| 1045 |
Currency : @key(in) String := Default_Currency; |
| 1046 |
Fill : @key(in) Character := Default_Fill; |
| 1047 |
Separator : @key(in) Character := Default_Separator; |
| 1048 |
Radix_Mark : @key(in) Character := Default_Radix_Mark) |
| 1049 |
@key(return) String; |
| 1050 |
|
| 1051 |
@ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0241-1]} |
| 1052 |
@key(procedure) @AdaSubDefn{Put} (File : @key(in) File_Type; |
| 1053 |
Item : @key(in) Num; |
| 1054 |
Pic : @key(in) Picture; |
| 1055 |
Currency : @key(in) String := Default_Currency; |
| 1056 |
Fill : @key(in) Character := Default_Fill; |
| 1057 |
Separator : @key(in) Character := Default_Separator; |
| 1058 |
Radix_Mark : @key(in) Character := Default_Radix_Mark)@Chg{Version=[5],New=[ |
| 1059 |
@key(with) Nonblocking => False],Old=[]}; |
| 1060 |
|
| 1061 |
@ChgRef{Version=[5],Kind=[Revised],ARef=[AI12-0241-1]} |
| 1062 |
@key(procedure) @AdaSubDefn{Put} (Item : @key(in) Num; |
| 1063 |
Pic : @key(in) Picture; |
| 1064 |
Currency : @key(in) String := Default_Currency; |
| 1065 |
Fill : @key(in) Character := Default_Fill; |
| 1066 |
Separator : @key(in) Character := Default_Separator; |
| 1067 |
Radix_Mark : @key(in) Character := Default_Radix_Mark)@Chg{Version=[5],New=[ |
| 1068 |
@key(with) Nonblocking => False],Old=[]}; |
| 1069 |
|
| 1070 |
@trailing@; @key(procedure) @AdaSubDefn{Put} (To : @key(out) String; |
| 1071 |
Item : @key(in) Num; |
| 1072 |
Pic : @key(in) Picture; |
| 1073 |
Currency : @key(in) String := Default_Currency; |
| 1074 |
Fill : @key(in) Character := Default_Fill; |
| 1075 |
Separator : @key(in) Character := Default_Separator; |
| 1076 |
Radix_Mark : @key(in) Character := Default_Radix_Mark); |
| 1077 |
@key(end) Decimal_Output; |
| 1078 |
@key(private) |
| 1079 |
... @RI{-- not specified by the language} |
| 1080 |
@key(end) Ada.Text_IO.Editing; |
| 1081 |
@end{Example} |
| 1082 |
@ImplDef{The value of Max_Picture_Length in the package Text_IO.Editing} |
| 1083 |
|
| 1084 |
@Trailing@;The exception Constraint_Error is raised |
| 1085 |
if the Image function or any of the |
| 1086 |
Put procedures is invoked with a null string for Currency. |
| 1087 |
@begin{DescribeCode} |
| 1088 |
@begin{Example}@Keepnext |
| 1089 |
@key(function) Valid (Pic_String : @key(in) String; |
| 1090 |
Blank_When_Zero : @key(in) Boolean := False) @key(return) Boolean; |
| 1091 |
@end{Example} |
| 1092 |
@Trailing@;Valid returns True if Pic_String is a well-formed picture String |
| 1093 |
(see @RefSecNum(Picture String Formation)) the |
| 1094 |
length of whose expansion does not exceed Max_Picture_Length, and if |
| 1095 |
either Blank_When_Zero is False or Pic_String contains no '*'. |
| 1096 |
|
| 1097 |
@begin{Example}@Keepnext |
| 1098 |
@key(function) To_Picture (Pic_String : @key(in) String; |
| 1099 |
Blank_When_Zero : @key(in) Boolean := False) |
| 1100 |
@key(return) Picture; |
| 1101 |
@end{Example} |
| 1102 |
@Trailing@;To_Picture returns a result Picture such that the application of the |
| 1103 |
function Pic_String to this result |
| 1104 |
yields an expanded picture String equivalent to Pic_String, and such |
| 1105 |
that Blank_When_Zero applied to the result Picture is the same value as the |
| 1106 |
parameter Blank_When_Zero. |
| 1107 |
Picture_Error is raised if not |
| 1108 |
Valid(Pic_String, Blank_When_Zero). |
| 1109 |
|
| 1110 |
@begin{Example} |
| 1111 |
@key(function) Pic_String (Pic : @key(in) Picture) @key(return) String; |
| 1112 |
@Comment{Blank line} |
| 1113 |
@key(function) Blank_When_Zero (Pic : @key(in) Picture) @key(return) Boolean; |
| 1114 |
@end{Example} |
| 1115 |
@Leading@;If Pic is To_Picture(String_Item, Boolean_Item) for some String_Item and |
| 1116 |
Boolean_Item, then: |
| 1117 |
@begin[itemize] |
| 1118 |
Pic_String(Pic) returns an expanded picture String |
| 1119 |
equivalent to String_Item and with any lower-case letter |
| 1120 |
replaced with its corresponding upper-case form, and |
| 1121 |
|
| 1122 |
Blank_When_Zero(Pic) returns Boolean_Item. |
| 1123 |
@end[Itemize] |
| 1124 |
|
| 1125 |
@Leading@;If Pic_1 and Pic_2 are objects of type Picture, then "="(Pic_1, Pic_2) |
| 1126 |
is True when |
| 1127 |
@begin[itemize] |
| 1128 |
Pic_String(Pic_1) = Pic_String(Pic_2), and |
| 1129 |
|
| 1130 |
@Trailing@;Blank_When_Zero(Pic_1) = Blank_When_Zero(Pic_2). |
| 1131 |
@end[Itemize] |
| 1132 |
|
| 1133 |
@begin{Example}@Keepnext |
| 1134 |
@key(function) Length (Pic : @key(in) Picture; |
| 1135 |
Currency : @key(in) String := Default_Currency) |
| 1136 |
@key(return) Natural; |
| 1137 |
@end{Example} |
| 1138 |
@Leading@;Length returns Pic_String(Pic)'Length + Currency_Length_Adjustment @en |
| 1139 |
Radix_Adjustment where |
| 1140 |
@begin[itemize] |
| 1141 |
@Leading@;Currency_Length_Adjustment = |
| 1142 |
@begin[Inneritemize] |
| 1143 |
Currency'Length @en@; 1 if there is some occurrence of '$' in |
| 1144 |
Pic_String(Pic), and |
| 1145 |
|
| 1146 |
0 otherwise. |
| 1147 |
@end[Inneritemize] |
| 1148 |
|
| 1149 |
@Leading@;Radix_Adjustment = |
| 1150 |
@begin[Inneritemize] |
| 1151 |
1 if there is an occurrence of 'V' or 'v' in Pic_Str(Pic), and |
| 1152 |
|
| 1153 |
@Trailing@;0 otherwise. |
| 1154 |
@end[Inneritemize] |
| 1155 |
@end[itemize] |
| 1156 |
|
| 1157 |
@begin{Example}@Keepnext |
| 1158 |
@key(function) Valid (Item : @key(in) Num; |
| 1159 |
Pic : @key(in) Picture; |
| 1160 |
Currency : @key(in) String := Default_Currency) |
| 1161 |
@key(return) Boolean; |
| 1162 |
@end{Example} |
| 1163 |
@Trailing@;Valid returns True if Image(Item, Pic, Currency) does not raise |
| 1164 |
Layout_Error, and returns False otherwise. |
| 1165 |
|
| 1166 |
@begin{Example} |
| 1167 |
@key(function) Image (Item : @key(in) Num; |
| 1168 |
Pic : @key(in) Picture; |
| 1169 |
Currency : @key(in) String := Default_Currency; |
| 1170 |
Fill : @key(in) Character := Default_Fill; |
| 1171 |
Separator : @key(in) Character := Default_Separator; |
| 1172 |
Radix_Mark : @key(in) Character := Default_Radix_Mark) |
| 1173 |
@key(return) String; |
| 1174 |
@end{Example} |
| 1175 |
@Trailing@;Image returns the edited output String as defined in |
| 1176 |
@RefSecNum(Edited Output Generation) for Item, |
| 1177 |
Pic_String(Pic), Blank_When_Zero(Pic), |
| 1178 |
Currency, Fill, Separator, |
| 1179 |
and Radix_Mark. If these rules identify a layout error, then Image |
| 1180 |
raises the exception Layout_Error. |
| 1181 |
|
| 1182 |
@begin{Example} |
| 1183 |
@key(procedure) Put (File : @key(in) File_Type; |
| 1184 |
Item : @key(in) Num; |
| 1185 |
Pic : @key(in) Picture; |
| 1186 |
Currency : @key(in) String := Default_Currency; |
| 1187 |
Fill : @key(in) Character := Default_Fill; |
| 1188 |
Separator : @key(in) Character := Default_Separator; |
| 1189 |
Radix_Mark : @key(in) Character := Default_Radix_Mark); |
| 1190 |
@Comment{Blank line} |
| 1191 |
@key(procedure) Put (Item : @key(in) Num; |
| 1192 |
Pic : @key(in) Picture; |
| 1193 |
Currency : @key(in) String := Default_Currency; |
| 1194 |
Fill : @key(in) Character := Default_Fill; |
| 1195 |
Separator : @key(in) Character := Default_Separator; |
| 1196 |
Radix_Mark : @key(in) Character := Default_Radix_Mark); |
| 1197 |
@end{Example} |
| 1198 |
@Trailing@;Each of these Put procedures |
| 1199 |
outputs Image(Item, Pic, Currency, Fill, Separator, Radix_Mark) |
| 1200 |
consistent with the conventions for Put for other real types in case |
| 1201 |
of bounded line length (see @RefSec{Get and Put Procedures}). |
| 1202 |
|
| 1203 |
@begin{Example} |
| 1204 |
@key(procedure) Put (To : @key(out) String; |
| 1205 |
Item : @key(in) Num; |
| 1206 |
Pic : @key(in) Picture; |
| 1207 |
Currency : @key(in) String := Default_Currency; |
| 1208 |
Fill : @key(in) Character := Default_Fill; |
| 1209 |
Separator : @key(in) Character := Default_Separator; |
| 1210 |
Radix_Mark : @key(in) Character := Default_Radix_Mark); |
| 1211 |
@end{Example} |
| 1212 |
|
| 1213 |
@ChgRef{Version=[3],Kind=[Revised],ARef=[AI05-0264-1]} |
| 1214 |
Put copies Image(Item, Pic, Currency, Fill, Separator, Radix_Mark) |
| 1215 |
to the given string, right justified. Otherwise@Chg{Version=[3],New=[,],Old=[]} |
| 1216 |
unassigned Character values |
| 1217 |
in To are assigned the space character. If To'Length is less than |
| 1218 |
the length of the string resulting from Image, then Layout_Error is raised. |
| 1219 |
@end{DescribeCode} |
| 1220 |
@end{StaticSem} |
| 1221 |
|
| 1222 |
@begin{ImplReq} |
| 1223 |
Max_Picture_Length shall be at least 30. |
| 1224 |
The implementation shall support currency strings of length |
| 1225 |
up to at least 10, both for Default_Currency in an instantiation of |
| 1226 |
Decimal_Output, and for Currency in an invocation of Image or any |
| 1227 |
of the Put procedures. |
| 1228 |
@begin{Discussion} |
| 1229 |
This implies that a picture string with character replications |
| 1230 |
need not be supported (i.e., To_Picture will raise Picture_Error) |
| 1231 |
if its expanded form exceeds 30 characters. |
| 1232 |
@end{Discussion} |
| 1233 |
@end{ImplReq} |
| 1234 |
|
| 1235 |
@begin{Notes} |
| 1236 |
@Leading@;The rules for edited output are based on COBOL (ANSI X3.23:1985, |
| 1237 |
endorsed by ISO as ISO 1989-1985), with the |
| 1238 |
following differences: |
| 1239 |
@begin{Itemize} |
| 1240 |
The COBOL provisions for picture string localization and for 'P' format |
| 1241 |
are absent from Ada. |
| 1242 |
|
| 1243 |
@Leading@;The following Ada facilities are not in COBOL: |
| 1244 |
@begin{InnerItemize} |
| 1245 |
currency symbol placement after the number, |
| 1246 |
|
| 1247 |
localization of edited output string for multi-character |
| 1248 |
currency string values, including support for both length-preserving |
| 1249 |
and length-expanding currency symbols in picture strings |
| 1250 |
|
| 1251 |
localization of the radix mark, digits separator, and |
| 1252 |
fill character, and |
| 1253 |
|
| 1254 |
parenthesization of negative values. |
| 1255 |
@end{InnerItemize} |
| 1256 |
@end{Itemize} |
| 1257 |
@ChgNote{The following paragraph is missing a number in the original version. |
| 1258 |
To give it a number in the new version, it is marked as an insertion.} |
| 1259 |
@ChgRef{Version=[0],Kind=[Added]}@NoPrefix |
| 1260 |
@Chg{New=[],Old=[@Noparanum@;]}The value of 30 for Max_Picture_Length is the |
| 1261 |
same limit as in COBOL. |
| 1262 |
@end{Notes} |
| 1263 |
|
| 1264 |
@begin{Reason} |
| 1265 |
There are several reasons we have not adopted the COBOL-style permission to |
| 1266 |
provide a single-character replacement in the picture string for the `$' as |
| 1267 |
currency symbol, or to interchange the roles of `.' and `,' in picture strings |
| 1268 |
@begin{Itemize} |
| 1269 |
It would have introduced considerable complexity into Ada, as well as |
| 1270 |
confusion between run-time and compile-time character interpretation, since |
| 1271 |
picture Strings are dynamically computable in Ada, in contrast with COBOL |
| 1272 |
|
| 1273 |
Ada's rules for real literals provide a natural interpretation of `_' as |
| 1274 |
digits separator and `.' for radix mark; it is not essential to allow these to |
| 1275 |
be localized in picture strings, since Ada does not allow them to be localized |
| 1276 |
in real literals. |
| 1277 |
|
| 1278 |
The COBOL restriction for the currency symbol in a picture string to be |
| 1279 |
replaced by |
| 1280 |
a single character currency symbol is a compromise |
| 1281 |
solution. For general international usage |
| 1282 |
a mechanism is needed to localize the edited output to |
| 1283 |
be a multi-character currency string. Allowing a single-Character |
| 1284 |
localization for the picture Character, and a multiple-character localization |
| 1285 |
for the currency string, would be an unnecessary complication. |
| 1286 |
@end{Itemize} |
| 1287 |
@end{Reason} |
| 1288 |
|
| 1289 |
@LabeledSubClause{The Package Wide_Text_IO.Editing} |
| 1290 |
|
| 1291 |
@begin{StaticSem} |
| 1292 |
@Leading@;@Defn{Ada.Wide_@!Text_IO.Editing} |
| 1293 |
@ChildUnit{Parent=[Ada.Wide_@!Text_IO],Child=[Editing]} |
| 1294 |
The child package Wide_Text_IO.Editing has |
| 1295 |
the same contents as Text_IO.Editing, except that: |
| 1296 |
@begin{Itemize} |
| 1297 |
each occurrence of Character is replaced by Wide_Character, |
| 1298 |
|
| 1299 |
each occurrence of Text_IO is replaced by Wide_Text_IO, |
| 1300 |
|
| 1301 |
the subtype of Default_Currency is Wide_String rather than String, and |
| 1302 |
|
| 1303 |
each occurrence of String |
| 1304 |
in the generic package Decimal_Output is replaced by |
| 1305 |
Wide_String. |
| 1306 |
@end{Itemize} |
| 1307 |
@ImplDef{The value of Max_Picture_Length in the package Wide_Text_IO.Editing} |
| 1308 |
@end{StaticSem} |
| 1309 |
|
| 1310 |
@begin{Notes} |
| 1311 |
Each of the functions Wide_Text_IO.Editing.Valid, To_Picture, and Pic_String has String (versus |
| 1312 |
Wide_String) as its parameter or result subtype, since a picture String |
| 1313 |
is not localizable. |
| 1314 |
@end{Notes} |
| 1315 |
|
| 1316 |
@LabeledAddedSubClause{Version=[2],Name=[The Package Wide_Wide_Text_IO.Editing]} |
| 1317 |
|
| 1318 |
|
| 1319 |
@begin{StaticSem} |
| 1320 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]} |
| 1321 |
@ChgAdded{Version=[2],Type=[Leading],Text=[@Defn{Ada.Wide_@!Wide_@!Text_IO.Editing} |
| 1322 |
@ChildUnit{Parent=[Ada.Wide_@!Wide_@!Text_IO],Child=[Editing]} |
| 1323 |
The child package Wide_Wide_Text_IO.Editing has |
| 1324 |
the same contents as Text_IO.Editing, except that:]} |
| 1325 |
@begin{Itemize} |
| 1326 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1327 |
@ChgAdded{Version=[2],Text=[each occurrence of Character is replaced by |
| 1328 |
Wide_Wide_Character,]} |
| 1329 |
|
| 1330 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1331 |
@ChgAdded{Version=[2],Text=[each occurrence of Text_IO is replaced by |
| 1332 |
Wide_Wide_Text_IO,]} |
| 1333 |
|
| 1334 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1335 |
@ChgAdded{Version=[2],Text=[the subtype of Default_Currency is Wide_Wide_String |
| 1336 |
rather than String, and]} |
| 1337 |
|
| 1338 |
@ChgRef{Version=[2],Kind=[AddedNormal]} |
| 1339 |
@ChgAdded{Version=[2],Text=[each occurrence of String |
| 1340 |
in the generic package Decimal_Output is replaced by |
| 1341 |
Wide_Wide_String.]} |
| 1342 |
@end{Itemize} |
| 1343 |
@ChgImplDef{Version=[2],Kind=[AddedNormal],Text=[@Chg{Version=[2],New=[The |
| 1344 |
value of Max_Picture_Length in the package Wide_Wide_Text_IO.Editing],Old=[]}]} |
| 1345 |
|
| 1346 |
@end{StaticSem} |
| 1347 |
|
| 1348 |
@begin{Notes} |
| 1349 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]} |
| 1350 |
@ChgAdded{Version=[2],Text=[Each of the functions |
| 1351 |
Wide_Wide_Text_IO.Editing.Valid, To_Picture, and Pic_String has String (versus |
| 1352 |
Wide_Wide_String) as its parameter or result subtype, since a picture String is |
| 1353 |
not localizable.]} |
| 1354 |
@end{Notes} |
| 1355 |
|
| 1356 |
@begin{Extend95} |
| 1357 |
@ChgRef{Version=[2],Kind=[AddedNormal],ARef=[AI95-00285-01]} |
| 1358 |
@ChgAdded{Version=[2],Text=[@Defn{extensions to Ada 95} |
| 1359 |
Package Wide_Wide_Text_IO.Editing is new; it supports 32-bit character |
| 1360 |
strings. (Shouldn't it have been |
| 1361 |
@lquotes@;Widest_Text_IO.Editing@rquotes@;? :-)]} |
| 1362 |
@end{Extend95} |
| 1363 |
|
| 1364 |
|