Go to the first, previous, next, last section, table of contents.


F.3.2 Edited Output Generation

Dynamic Semantics

  1. The contents of an edited output string are based on:
    1. A value, Item, of some decimal type Num,
    2. An expanded picture String Pic_String,
    3. A Boolean value, Blank_When_Zero,
    4. A Currency string,
    5. A Fill character,
    6. A Separator character, and
    7. A Radix_Mark character.

  1. The combination of a True value for Blank_When_Zero and a '*' character in Pic_String is inconsistent; no edited output string is defined.
  2. 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.
  3. The edited output string has lower bound 1 and upper bound N where N = Pic_String'Length + Currency_Length_Adjustment - Radix_Adjustment, and
    1. Currency_Length_Adjustment = Currency'Length - 1 if there is some occurrence of '$' in Pic_String, and 0 otherwise.
    2. Radix_Adjustment = 1 if there is an occurrence of 'V' or 'v' in Pic_Str, and 0 otherwise.
    3. Let the magnitude of Item be expressed as a base-10 number
      I ***I .F ***F , called the displayed magnitude of Item, where:
       p    1  1    q
      
    4. 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).
    5. I  /= 0 if p>0.
       p
      

  1. If n < Num'Scale, then the above number is the result of rounding (away from 0 if exactly midway between values).
  2. 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 See section F.3.1 Picture String Formation, and the edited output string is the concatenation of string values derived from these categories according to the following mapping rules.
  3. 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   | Edited Output    | Edited Output |
        | Symbol         | for Non-Negative | for Negative  |
        |                | Number           | Number        |
        |                |                  |               |
        +----------------+------------------+---------------+
        |                |                  |               |
        |      '+'       |        '+'       |      '-'      |
        |                |                  |               |
        |      '-'       |        'b'       |      '-'      |
        |                |                  |               |
        |      '<'       |        'b'       |      '('      |
        |                |                  |               |
        |      '>'       |        'b'       |      ')'      |
        |                |                  |               |
        |     "CR"       |       "bb"       |     "CR"      |
        |                |                  |               |
        |     "DB"       |       "bb"       |     "DB"      |
        |                |                  |               |
        +----------------+------------------+---------------+
    
  4. An instance of fixed_LHS_sign maps to a character as shown in Table F-1.
  5. An instance of fixed_$_char maps to Currency.
  6. An instance of direct_insertion maps to Separator if direct_insertion = '_', and to the direct_insertion Character otherwise.
  7. An instance of number maps to a string integer_part & radix_part & fraction_part where:
    1. The string for integer_part is obtained as follows:
      1. Occurrences of '9' in fore_digits of number are replaced
        from right to left with the decimal digit character values
        for I , ..., I , respectively.
             1        p
        
      2. Each occurrence of '9' in fore_digits to the left of the leftmost '9' replaced according to rule 1 is replaced with '0'.
      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.

    1. The radix_part is:
      1. "" if number does not include a radix, if radix = 'V', or if radix = 'v'
      2. Radix_Mark if number includes '.' as radix

    1. The string for fraction_part is obtained as follows:
      1. Occurrences of '9' in aft_digits of number are replaced
        from left to right with the decimal digit character values
        for F , ... F .
             1       q
        
      2. Each occurrence of '9' in aft_digits to the right of the rightmost '9' replaced according to rule 1 is replaced by '0'.

  1. An instance of zero_suppression maps to the string obtained as follows:
    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,
    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,
    3. Each Character to the left of the leftmost Character replaced according to rule 1 above is replaced by:
      1. the space character if the zero suppression Character is 'Z' or 'z', or
      2. the Fill character if the zero suppression Character is '*'.

    1. 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.

  1. An instance of RHS_sign maps to a character or string as shown in Table F-1.
  2. An instance of floating_LHS_sign maps to the string obtained as follows.
    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.
    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.
    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.
    4. Any other Character is replaced by the space character..
    5. A layout error occurs if some excess digits remain after replacement via rule 1; no edited output string is produced.

  1. 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.
  2. An instance of floating_$_currency maps to the string obtained as follows:
    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.
    2. The next Character to the left is replaced by the Currency string.
    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.
    4. Each other Character is replaced by the space character.
    5. A layout error occurs if some excess digits remain after replacement by rule 1; no edited output string is produced.

  1. An instance of floating_#_currency maps to the string obtained as follows:
    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.
    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.
    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.
    4. Any other Character is replaced by the space character.
    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.

  1. An instance of all_zero_suppression_number maps to:
    1. 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;
    2. 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;
    3. 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.

  1. An instance of all_sign_number maps to:
    1. 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;
    2. 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.

  1. An instance of all_currency_number maps to:
    1. 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;
    2. 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

  1. In the result string values shown below, 'b' represents the space character.
  2. Item:         Picture and Result Strings:
    
  3. 123456.78     Picture:  "-###**_***_**9.99"
                            "bbb$***123,456.78"
                            "bbFF***123.456,78" (currency = "FF",
                                                 separator = '.',
                                                 radix mark = ',')
    
  4. 123456.78     Picture:  "-$$$**_***_**9.99"
                  Result:   "bbb$***123,456.78"
                            "bbbFF***123.456,78" (currency = "FF",
                                                  separator = '.',
                                                  radix mark = ',')
    
  5. 0.0          Picture: "-$$$$$$.$$"
                 Result:  "bbbbbbbbbb"
    
  6. 0.20         Picture: "-$$$$$$.$$"
                 Result:  "bbbbbb$.20"
    
  7. -1234.565    Picture: "<<<<_<<<.<<###>"
                 Result:  "bb(1,234.57DMb)"  (currency = "DM")
    
  8. 12345.67     Picture: "###_###_##9.99"
                 Result:  "bbCHF12,345.67"   (currency = "CHF")
    


Go to the first, previous, next, last section, table of contents.