IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

a question about packed-decimal.


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
sungang77

New User


Joined: 03 Nov 2005
Posts: 46
Location: Shanghai, China

PostPosted: Tue Nov 22, 2005 11:54 am
Reply with quote

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
View user's profile Send private message
reshma

New User


Joined: 10 Sep 2005
Posts: 9
Location: software engineer

PostPosted: Tue Nov 22, 2005 3:52 pm
Reply with quote

hi,

i think choice 1 is the answer for ur question
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Wed Nov 23, 2005 7:47 am
Reply with quote

I choose 3. The V is an IMPLIED decimal point.
Back to top
View user's profile Send private message
sungang77

New User


Joined: 03 Nov 2005
Posts: 46
Location: Shanghai, China

PostPosted: Wed Nov 23, 2005 8:12 am
Reply with quote

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
View user's profile Send private message
subhra das

New User


Joined: 01 Aug 2005
Posts: 9

PostPosted: Wed Nov 23, 2005 3:01 pm
Reply with quote

Hi,
choice 3 is the correct answer.
Back to top
View user's profile Send private message
sureshchoudey

New User


Joined: 16 Sep 2005
Posts: 12

PostPosted: Wed Nov 23, 2005 8:08 pm
Reply with quote

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
View user's profile Send private message
k_vikram07

New User


Joined: 23 Nov 2005
Posts: 35

PostPosted: Thu Nov 24, 2005 12:30 am
Reply with quote

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
View user's profile Send private message
sungang77

New User


Joined: 03 Nov 2005
Posts: 46
Location: Shanghai, China

PostPosted: Thu Nov 24, 2005 7:13 am
Reply with quote

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
View user's profile Send private message
subhra das

New User


Joined: 01 Aug 2005
Posts: 9

PostPosted: Thu Nov 24, 2005 9:23 am
Reply with quote

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
View user's profile Send private message
k_vikram07

New User


Joined: 23 Nov 2005
Posts: 35

PostPosted: Thu Nov 24, 2005 12:37 pm
Reply with quote

Thanks sungang, subhra.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts PD not working for unsigned packed JO... DFSORT/ICETOOL 5
No new posts Def PD not working for unsigned packe... JCL & VSAM 3
No new posts Question for file manager IBM Tools 7
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
Search our Forums:

Back to Top