View previous topic :: View next topic
|
Author |
Message |
vsvsankar
New User
Joined: 10 Mar 2004 Posts: 7
|
|
|
|
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 |
|
Back to top |
|
|
mdtendulkar
Active User
Joined: 29 Jul 2003 Posts: 237 Location: USA
|
|
Back to top |
|
|
mcmillan
Site Admin
Joined: 18 May 2003 Posts: 1210 Location: India
|
|
|
|
Dear,
COMP-1 & COMP-2 have predefined PICTURE clauses as:
COMP-1 : SV9(8)ES99
COMP-2: SV9(17)ES99 |
|
Back to top |
|
|
vsvsankar
New User
Joined: 10 Mar 2004 Posts: 7
|
|
|
|
Hi,
Thanks for your prompt response.
Vijai |
|
Back to top |
|
|
praveenhj
New User
Joined: 05 Apr 2005 Posts: 6 Location: bangalore
|
|
|
|
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
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 |
|
|
nave
New User
Joined: 16 May 2005 Posts: 10 Location: bangalore,india
|
|
|
|
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 |
|
|
prav_06 Warnings : 1 Active User
Joined: 13 Dec 2005 Posts: 154 Location: The Netherlands
|
|
|
|
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 |
|
|
Brian's_song
New User
Joined: 27 Dec 2005 Posts: 21
|
|
|
|
Hi all,
ANd How about the Com-3 and Display ?
Thanks. |
|
Back to top |
|
|
ap_mainframes
Active User
Joined: 29 Dec 2005 Posts: 181 Location: Canada
|
|
|
|
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 |
|
|
tushar_zibbu
New User
Joined: 10 Jan 2006 Posts: 3
|
|
|
|
Ya I am also confused about this SV and ES concept. Can anyone please explain.
Regards,
Tushar |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
S denotes the sign.
V denotes an implied decimal place.
E denotes an exponent. |
|
Back to top |
|
|
DeepaBala
New User
Joined: 20 Feb 2007 Posts: 13 Location: Trivandrum
|
|
|
|
Thanks for the useful question and a great replies |
|
Back to top |
|
|
kshalini
New User
Joined: 20 Feb 2007 Posts: 8 Location: Banglore
|
|
|
|
can any1 explain where we use comp-1 and comp-2 and the pic clause mentioned exactly means what |
|
Back to top |
|
|
agkshirsagar
Active Member
Joined: 27 Feb 2007 Posts: 691 Location: Earth
|
|
|
|
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? |
|
Back to top |
|
|
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 127 Location: kerala,india
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 127 Location: kerala,india
|
|
|
|
yes dick but packed decimal itself is a form of binary format |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Why would you think that
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 |
|
|
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 127 Location: kerala,india
|
|
|
|
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 |
|
|
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 127 Location: kerala,india
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
cobolunni
Active User
Joined: 07 Aug 2006 Posts: 127 Location: kerala,india
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
|