How many bytes does a S9(7) SIGN TRAILING SEPARATE field occupy ?

  1. 3 bytes

  2. 4 bytes

  3. 7 bytes

  4. 8 bytes


Correct Option: D
Explanation:

To solve this question, the user needs to be familiar with the format of COBOL numeric fields.

In COBOL, S9(7) SIGN TRAILING SEPARATE represents a numeric field with a maximum of 7 digits, including the sign (positive or negative) and a separator character (usually a comma or a period) that separates the integer and decimal portions of the number. The "SIGN TRAILING SEPARATE" clause specifies that the sign character appears after the digits of the number, while the separator character appears between the last two digits of the integer portion and the first decimal digit.

Now, let's go through each option and explain why it is right or wrong:

A. 3 bytes: This option is incorrect. A numeric field with the "SIGN TRAILING SEPARATE" clause always occupies an even number of bytes. Since the maximum number of digits in S9(7) is 7, and the sign and separator characters each occupy one byte, the field must occupy at least 9 bytes (7 digits + 1 sign + 1 separator).

B. 4 bytes: This option is incorrect for the same reason as option A. A S9(7) SIGN TRAILING SEPARATE field must occupy an even number of bytes, which is at least 9 bytes.

C. 7 bytes: This option is incorrect. As explained above, a S9(7) SIGN TRAILING SEPARATE field must occupy an even number of bytes. Additionally, 7 bytes is not enough to store a 7-digit number with a sign and a separator character.

D. 8 bytes: This option is correct. A S9(7) SIGN TRAILING SEPARATE field must occupy an even number of bytes, which is at least 9 bytes. However, if the number is positive, the sign character is represented by a low-value (i.e., hex 'F') in the leftmost byte of the field. Therefore, if the number is positive, the field occupies only 8 bytes, which is the correct answer.

The Answer is: D

Find more quizzes: