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

[Closed]Why COMP-1 and COMP-2 dont hav picture clause


IBM Mainframe Forums -> COBOL Programming
Post new topic   This topic is locked: you cannot edit posts or make replies.
View previous topic :: View next topic  
Author Message
vsvsankar

New User


Joined: 10 Mar 2004
Posts: 7

PostPosted: Wed Mar 10, 2004 7:42 pm
Reply with quote

Hi,
I hav seen the answers to the above question.but still it is vague to me.can anyone explain it to me in detail

Thanks,
Vijai icon_smile.gif
Back to top
View user's profile Send private message
mdtendulkar

Active User


Joined: 29 Jul 2003
Posts: 237
Location: USA

PostPosted: Thu Mar 11, 2004 10:54 am
Reply with quote

Hello vsvsankar,

Look at the following link

www.cis.scu.edu.tw/oproom/doc/acucobol/docs/comprun/gt400419.htm

Hope this helps

Regards

Mayuresh Tendulkar
Back to top
View user's profile Send private message
mcmillan

Site Admin


Joined: 18 May 2003
Posts: 1210
Location: India

PostPosted: Fri Mar 12, 2004 8:40 pm
Reply with quote

Dear,

COMP-1 & COMP-2 have predefined PICTURE clauses as:

COMP-1 : SV9(8)ES99

COMP-2: SV9(17)ES99
Back to top
View user's profile Send private message
vsvsankar

New User


Joined: 10 Mar 2004
Posts: 7

PostPosted: Sun Mar 14, 2004 12:33 pm
Reply with quote

Hi,
Thanks for your prompt response.

Vijai
Back to top
View user's profile Send private message
praveenhj

New User


Joined: 05 Apr 2005
Posts: 6
Location: bangalore

PostPosted: Sat May 14, 2005 12:01 pm
Reply with quote

mcmillan wrote:
Dear,

Who told you as, COMP-1 & COMP-2 don't have PICTURE clause?

They have predefined PICTURE clauses as:

COMP-1 : SV9(8)ES99

COMP-2: SV9(17)ES99



what is that ES i'm not getting u, can u explain in clear.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Mon May 16, 2005 4:18 am
Reply with quote

The eCOBOL Pgmr Ref states that COMP-1 & 2 data items cannot have PIC strings. Probably because the length of the item is fixed, whether it contains a value of 1 or 1 billion:

It contains a sign in the hi-ord bit, a 7 bit exponent, and the maining 3 bytes (COMP-1) or 7 bytes (COMP-2) define the mantissa.
Back to top
View user's profile Send private message
nave

New User


Joined: 16 May 2005
Posts: 10
Location: bangalore,india

PostPosted: Mon May 16, 2005 6:05 pm
Reply with quote

as jack said,
comp1 takes 4 bytes of memory space and comp2 takes 8 bytes of memory space .so no need of specyfying the bytes,then comp allowed only for numerics so no need of pic also
Back to top
View user's profile Send private message
prav_06
Warnings : 1

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Tue Jan 24, 2006 3:41 pm
Reply with quote

Hi,
we indicate PICTURE clause for all the data types we declare, u shd first understand the need of this picture clause if u want to know why comp-1 and 2 does not have picture clause, c this PICTURE clause is the one which allocates the memory for the data item u have declared during the run time for eg
77 a pic 999.
when u using the above identifier in any operationinside u r cobol pgm it needs 3 bytes of memory durin the run time , PICTURE clause is one which is responsiable for this memory allocation, but when u consider COMP-1 or COMP-2 , the memory occupied by these variables are predefined as 1 word and 2 word respectively, so there is no use of coding PICTURE clause for COMP-1 and COMP-2 variables
Back to top
View user's profile Send private message
Brian's_song

New User


Joined: 27 Dec 2005
Posts: 21

PostPosted: Sun Feb 12, 2006 7:29 pm
Reply with quote

Hi all,
ANd How about the Com-3 and Display ?

Thanks.
Back to top
View user's profile Send private message
ap_mainframes

Active User


Joined: 29 Dec 2005
Posts: 181
Location: Canada

PostPosted: Tue Mar 28, 2006 9:16 pm
Reply with quote

Quote:
Who told you as, COMP-1 & COMP-2 don't have PICTURE clause?

They have predefined PICTURE clauses as:

COMP-1 : SV9(8)ES99

COMP-2: SV9(17)ES99


All,

This picture clause is still not clear to me.
What exactly is SV and ES signifing here.
I know why it wont need a picture clause but whats SV and ES here????
I have read all the previous replies but i dont think any of them is explaining this clearly.

Thanks
ap_mainframes
Back to top
View user's profile Send private message
tushar_zibbu

New User


Joined: 10 Jan 2006
Posts: 3

PostPosted: Fri Mar 31, 2006 2:05 am
Reply with quote

Ya I am also confused about this SV and ES concept. icon_rolleyes.gif icon_biggrin.gif Can anyone please explain.
Regards,
Tushar
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Apr 01, 2006 11:45 pm
Reply with quote

S denotes the sign.
V denotes an implied decimal place.
E denotes an exponent.
Back to top
View user's profile Send private message
DeepaBala

New User


Joined: 20 Feb 2007
Posts: 13
Location: Trivandrum

PostPosted: Thu Feb 22, 2007 10:27 am
Reply with quote

Thanks for the useful question and a great replies
Back to top
View user's profile Send private message
kshalini

New User


Joined: 20 Feb 2007
Posts: 8
Location: Banglore

PostPosted: Thu Mar 08, 2007 5:04 pm
Reply with quote

can any1 explain where we use comp-1 and comp-2 and the pic clause mentioned exactly means what
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 691
Location: Earth

PostPosted: Thu Mar 08, 2007 8:18 pm
Reply with quote

Don't get confused with the PICTURE clause. 'SV9(8)ES99' is 'IMPLICIT' pic clause when we declare COMP-1

Lets verify it practically with small experiment.
I am moving a very small negative value to COMP-1 variable
Code:

  01  WS-AMOUNT-NU COMP-1.   
  PROCEDURE DIVISION.
    MOVE -.0000099999 TO WS-AMOUNT-NU.     
    DISPLAY WS-AMOUNT-NU.               
   


this is what I got in my spool
-.99998997E-05
-0.0000099999 is .99999 * 10 ^ 05
self explanatory, isn't it? icon_biggrin.gif
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Thu Mar 08, 2007 11:14 pm
Reply with quote

kshalini wrote:
can any1 explain where we use comp-1 and comp-2 and the pic clause mentioned exactly means what


COMPUTATIONAL or COMP is used in the case of arithmatic operations because computer uses binary form of integers to do the arithmatic process so it will be difficult to convert every time from default EBCDIC to binary when we need an arithmatic process. So we are going for comp also memmory management is another consideration

COMP has a default picture clause internaly so need to mension it
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Mar 08, 2007 11:31 pm
Reply with quote

Hello,

Not completely true.

Quote:
COMPUTATIONAL or COMP is used in the case of arithmatic operations because computer uses binary form of integers to do the arithmatic process

The computer does not always use binary arithmetic for computations (ASCII platforms typically do, but this forum is for mainframes).

In fact, business arithmetic on the mainframe is not binary most of the time. The mainframe has a complete set of packed-decimal arithmetic instructions. In most cases, the result of a calculation must be edited (i.e. $1,234.44-) for readability and the input to the edit instruction must be packed-decimal. If it is not, the system must first get the value into a packed-decimal field, so dollar fields and quantity fields are usually defined as packed-decimal.
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Thu Mar 08, 2007 11:41 pm
Reply with quote

yes dick but packed decimal itself is a form of binary format
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Mar 09, 2007 12:30 am
Reply with quote

Why would you think that icon_question.gif
Quote:
but packed decimal itself is a form of binary format

No, it is not - unless you want to say that everyting is a form of binary format.

The letter A is a hex 'C1' and in binary is '1100 0001'. I guess that is a binary format. Kinda silly, but it is binary. . . .

And yes, all 256 possible values for one byte have a binary internal storage of ones and zeros. That does not make them "binary format". The format is determined by the definition (i.e. PIC whatever).

Packed decimal by definition is not binary.
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Fri Mar 09, 2007 1:12 am
Reply with quote

dick scherrer wrote:
Packed decimal by definition is not binary.


defenition of packed decimal is
Quote:
Binary-coded decimal (BCD) is an encoding for decimal numbers in which each digit is represented by its own binary sequence.


so each digit is represented in binary format.

look at http://en.wikipedia.org/wiki/Binary-coded_decimal
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Fri Mar 09, 2007 1:17 am
Reply with quote

dick scherrer wrote:

In fact, business arithmetic on the mainframe is not binary most of the time.


thats wrong no electronic macheine in the world which can directly process data which is not converted into machiene language ie binary
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Mar 09, 2007 1:30 am
Reply with quote

You need to learn much more before you post such as this.
Quote:
no electronic macheine in the world which can directly process data which is not converted into machiene language ie binary


Packed-decimal is part of the machine language on the mainframe.

If you took the time to look at the generated assembler, and the machine code generated from that, you would learn that there are different machine instructions for packed-decimal arithmetic and binary aritmetic.

It really is time the moderator closes this topic.
Back to top
View user's profile Send private message
cobolunni

Active User


Joined: 07 Aug 2006
Posts: 127
Location: kerala,india

PostPosted: Fri Mar 09, 2007 2:04 am
Reply with quote

a computer machiene understands only binary or machiene language. if we need number 2 to be identified by computer it will be converted into binary ie 0010 the packed decimal for 2 is also 0010.

the difference bt binary and packed decimal is that

eg 12 binary is 1100 and bcd is 0001 0010 in both case actually we are converting a decimal into binary so packed decimal is a binary format inwhich each digit is represented in binary
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Mar 09, 2007 3:52 am
Reply with quote

cobolunni wrote:
a computer machiene understands only binary or machiene language. if we need number 2 to be identified by computer it will be converted into binary ie 0010 the packed decimal for 2 is also 0010.
Oh good, the magic word, "machine language"......On a machine language level (though the packed data is "represented" in binary - because that is how memory works), the machine language processing does not do binary math, it does packed decimal math. When it adds 2 + 2, it adds X'2C' to X'2C' and the result is X'4C'. It sees the digits a byte a a time.
Do you grasp this yet?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Fri Mar 09, 2007 5:42 am
Reply with quote

Hi Bill,

No, he doesn't. Earlier in the thread i tried to explain that but he is completely focused - incorrectly.

I believe his background is not mainframe and cannot relate to the fact that there really are machine instructions that are not binary on the mainframe.

Oh, well. Like i suggested earlier, probably a good time to close this thread.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   This topic is locked: you cannot edit posts or make replies. View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming Goto page 1, 2  Next

 


Similar Topics
Topic Forum Replies
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts To search DB2 table based on Conditio... DB2 1
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts Interviewers are surprised with my an... Mainframe Interview Questions 6
No new posts Cobol COMP-2 fields getting scrambled... Java & MQSeries 6
Search our Forums:

Back to Top