Multiple choice technology programming languages

How many bytes does a S9(7) COMP-3 field occupy ?

  1. 3

  2. 4

  3. 8

  4. 10

Reveal answer Fill a bubble to check yourself
B Correct answer
Explanation

COMP-3 (packed decimal) format stores two decimal digits per byte, plus one nibble for the sign. The formula is: bytes = (n/2) + 1. For S9(7): 7/2 = 3.5, rounded up to 4, plus 1 = 5, but the last nibble can hold the sign, so 4 bytes suffice. Actually, the standard formula gives: (7+1)/2 = 4 bytes. Each byte holds 2 digits except the last byte which holds 1 digit plus the sign nibble.