Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

a question about packed-decimal.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
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    Post subject: a question about packed-decimal.
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    Post subject: Re: a question about packed-decimal.
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    Post subject:
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    Post subject:
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    Post subject: answer
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    Post subject: Re: a question about packed-decimal.
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    Post subject:
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    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts READ A PACKED "NEGATIVE" FI... jdesouza CA Products 3 Tue May 02, 2017 11:43 pm
No new posts QUESTION: RETURN CHANNEL pahiker CA Products 21 Thu Apr 20, 2017 12:31 am
No new posts The Last Two Question For You To Ask ... CaptBill Mainframe Interview Questions 0 Fri Apr 14, 2017 5:42 am
No new posts Asynchronous CICS Processing Question moezbud CICS 1 Mon Mar 06, 2017 6:13 pm
No new posts CICS Question RE: Browse, Readnext an... moezbud CICS 7 Sun Mar 05, 2017 5:45 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us