View previous topic :: View next topic
|
Author |
Message |
sungang77
New User
Joined: 03 Nov 2005 Posts: 46 Location: Shanghai, China
|
|
|
|
Code: |
05 PAYCHECK PIC S9(4)V99 BINARY VALUE 234.56.
05 BONUS PIC S9(4)V99 BINARY VALUE 1000.00.
05 PAYCHECK-EDIT PIC ----.99.
ADD PAYCHECK, BONUS GIVING PAYCHECK-EDIT. |
Question:Which one of the following corrections needs to be made to the code above?
Choice 1
PAYCHECK-EDIT picture clause must be larger.
Choice 2
PAYCHECK and BONUS must be defined as S9(7)V99 if using BINARY.
Choice 3
PAYCHECK-EDIT must be the object of a MOVE statement, not a GIVING clause.
Choice 4
Usage must be PACKED-DECIMAL for decimal numbers, not BINARY.
Choice 5
PAYCHECK-EDIT picture clause must not contain nines. |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
hi frnd,
Mostly the posibility is for Choice 1 and Choice 4. since the Packed decimal can be used for Comp-3 and even the BINARY can also be used for decimal values i think option 1 will take precedence. So kindly check it i m not clear. Hope u r taking Brainbench test. Right!!!!!!! |
|
Back to top |
|
|
sungang77
New User
Joined: 03 Nov 2005 Posts: 46 Location: Shanghai, China
|
|
|
|
khamarutheen wrote: |
hi frnd,
Mostly the posibility is for Choice 1 and Choice 4. since the Packed decimal can be used for Comp-3 and even the BINARY can also be used for decimal values i think option 1 will take precedence. So kindly check it i m not clear. Hope u r taking Brainbench test. Right!!!!!!! |
Yes! It's Brainbench test question.
The following line,
05 PAYCHECK-EDIT PIC ----.99.
I'm not sure it's -(4)9.99 or -(3)9.99. I prefer to the latter. If PAYCHECK-EDIT is -(3)9.99, the answer must be 1. If not, must not be 1. I choose 1. |
|
Back to top |
|
|
khamarutheen
Active Member
Joined: 23 Aug 2005 Posts: 677 Location: NJ
|
|
|
|
hi frnd,
what do u mean by -(4)9.99 or -(3)9.99. i think u r confusing lot. the answer 1 will be right dont worry. All the best for the rest of the exam carry on. |
|
Back to top |
|
|
sungang77
New User
Joined: 03 Nov 2005 Posts: 46 Location: Shanghai, China
|
|
|
|
khamarutheen wrote: |
hi frnd,
what do u mean by -(4)9.99 or -(3)9.99. i think u r confusing lot. the answer 1 will be right dont worry. All the best for the rest of the exam carry on. |
-(4)9.99 means ----9.99.
-(3)9.99 means ---9.99.
I think PIC ----.99 equal to ---9.99. So I choose 1. |
|
Back to top |
|
|
sungang77
New User
Joined: 03 Nov 2005 Posts: 46 Location: Shanghai, China
|
|
|
|
sungang77 wrote: |
khamarutheen wrote: |
hi frnd,
what do u mean by -(4)9.99 or -(3)9.99. i think u r confusing lot. the answer 1 will be right dont worry. All the best for the rest of the exam carry on. |
-(4)9.99 means ----9.99.
-(3)9.99 means ---9.99.
I think PIC ----.99 equal to ---9.99. So I choose 1. |
Sorry.
What I mean is, ----.99 equal to ---9.99 equal to --99.99 equal to -999.99. |
|
Back to top |
|
|
DavidatK
Active Member
Joined: 22 Nov 2005 Posts: 700 Location: Troy, Michigan USA
|
|
|
|
Sungang77,
The correct answer is #1. Reason: the picture ----.99. is a floating signed display picture. i.e. if ur answer were negative 34.50, the resulting display would be -34.50. However, one place MUST be reserved for the sign, positive or negative. Therefore, with the picture clause you have defined, the maximum value you can display is 999.99. You are trying to display value of 1234.56. It will truncate to 234.56.
Enjoy, |
|
Back to top |
|
|
k_vikram07
New User
Joined: 23 Nov 2005 Posts: 35
|
|
|
|
Its long back I worked on COBOL.
I remember that we cannot declare the binary with a 'V' in picture clause.
If we change it to packed decimal, we can make it compilation error free.
And the result will be 1234.56, the sign is lost while displaying because of few char in edited field PAYCHECK-EDIT
Please correct me if i'm wrong... i'm currently into PL/1.
Thanks
Vik. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Vik,
I think a V in a binary field is OK. As I remember, the comiler converts the binary to packed. Also, it would be a serious no-no for a test ques to contain an unintended error.
With that edit definition the sign is never lost; the hi-ord numeric is truncated. |
|
Back to top |
|
|
|