View previous topic :: View next topic
|
Author |
Message |
sungang77
New User
Joined: 03 Nov 2005 Posts: 46 Location: Shanghai, China
|
|
|
|
Code: |
05 RETAIL-PRICE PIC S999V99 VALUE 749.95.
05 WK-PRICE PIC 99V99 PACKED-DECIMAL.
MOVE RETAIL-PRICE TO WK-PRICE
DISPLAY WK-PRICE. |
Question:Which one of the following is exactly what the above DISPLAY command shows?
Choice 1
49.95
Choice 2
74.49
Choice 3
4995
Choice 4
7449
Choice 5
7,449 |
|
Back to top |
|
|
reshma
New User
Joined: 10 Sep 2005 Posts: 9 Location: software engineer
|
|
|
|
hi,
i think choice 1 is the answer for ur question |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
I choose 3. The V is an IMPLIED decimal point. |
|
Back to top |
|
|
sungang77
New User
Joined: 03 Nov 2005 Posts: 46 Location: Shanghai, China
|
|
|
|
I think the answer must be in 3 or 4.
Like mmwife said, V is an IMPLIED decimal point, so it won't be shown.
I just wonder what will happen when a normal decimal is moved to a packed decimal. Will there anything special happen? |
|
Back to top |
|
|
subhra das
New User
Joined: 01 Aug 2005 Posts: 9
|
|
|
|
Hi,
choice 3 is the correct answer. |
|
Back to top |
|
|
sureshchoudey
New User
Joined: 16 Sep 2005 Posts: 12
|
|
|
|
The V is an IMPLIED decimal point.
Implied decimal point. A character (byte) is not used in the storage of a decimal point but its existence and position is implied. When the field is printed and used in a calculation, a decimal point is inserted at the point where the V appears. For example: a field defined as 9V9 should be interpreted as 9.9 but would be stored as 99. |
|
Back to top |
|
|
k_vikram07
New User
Joined: 23 Nov 2005 Posts: 35
|
|
|
|
answer is choice 1.
A DISPLAY will display the value in human readable format of the value. So it will be 49.95
Had it been written to some output file, then it will be seen as some junk of 3 char, and with hex on can be seen as
095
49D
because it is a packed-decimal one
Correct me if i'm wrong.
Thanks
Vik. |
|
Back to top |
|
|
sungang77
New User
Joined: 03 Nov 2005 Posts: 46 Location: Shanghai, China
|
|
|
|
k_vikram07 wrote: |
answer is choice 1.
A DISPLAY will display the value in human readable format of the value. So it will be 49.95
Had it been written to some output file, then it will be seen as some junk of 3 char, and with hex on can be seen as
095
49D
because it is a packed-decimal one
Correct me if i'm wrong.
Thanks
Vik. |
Hi Vik,
I think you are wrong.
A example in IBM library book -- Enterprise COBOL for z/os V3.4 Programming Guide. 1.3.2 Displaying numeric data.
Code: |
05 Price Pic 9(5)v99.
05 Edited-price-D Pic $99,999.99
Blank When Zero.
05 Edited-price-N Pic $99,999.99 Usage National
Blank When Zero.
. . .
Move 0 to Price
Move Price to Edited-price-D
Move Price to Edited-price-N
Display Edited-price-D
Display Edited-price-N upon console
Move Edited-price to Price
Display Price |
Price would be displayed as 0150099, representing the value
1,500.99. Price would also be displayed as 0150099 if Edited-price had USAGE NATIONAL.
So the answer is still 3.
If want to display a numeric as 49.95, the WK-PRICE should be defined like 99.99 |
|
Back to top |
|
|
subhra das
New User
Joined: 01 Aug 2005 Posts: 9
|
|
|
|
hi,
choice 1 is wrong . yes sungang u r write even i 've also tried this one .
it wont display the point in case of assumed decimal point.So choice 3 is the correct one. |
|
Back to top |
|
|
k_vikram07
New User
Joined: 23 Nov 2005 Posts: 35
|
|
|
|
Thanks sungang, subhra. |
|
Back to top |
|
|
|