View previous topic :: View next topic
|
Author |
Message |
cvijay784 Warnings : 1 New User
Joined: 18 Jun 2008 Posts: 54 Location: Colombo
|
|
|
|
Hi,
In cobol program, i have a numeric value 1234567890 which need to be loaded into a integer field of a table.
Hence I move these 10 digits to a S9(9) comp variable. After the movement, i see only 9 digits 234567890 in the output.
S9(9) COMP is equivalent of db2 integer. Integer can hold values up to 10 digits(-2147483648 till +2147483648) whereas cobol datatype holds only 9 digits.
This seems to be a contradiction. Please help me if you have any idea.
With Regards,
Vijay |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
When you tell cobol 9, you are limited to 9 (even though the storage could actually hold a bit more).
Quote: |
S9(9) COMP is equivalent of db2 integer. |
Ah, well, not quite. . .
s9(9) comp will fit into an integer field, but is not "equivalent". |
|
Back to top |
|
|
cvijay784 Warnings : 1 New User
Joined: 18 Jun 2008 Posts: 54 Location: Colombo
|
|
|
|
Thanks for letting me know that S9(9) comp will fit in Integer type but not exact equivalent.
I think S9(10) comp will be an equivalent when the values are limited between -2147483648 & +2147483648.
With Regards,
Vijay |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
cvijay784 wrote: |
Hi,
In cobol program, i have a numeric value 1234567890 which need to be loaded into a integer field of a table.
Hence I move these 10 digits to a S9(9) comp variable. After the movement, i see only 9 digits 234567890 in the output.
S9(9) COMP is equivalent of db2 integer. Integer can hold values up to 10 digits(-2147483648 till +2147483648) whereas cobol datatype holds only 9 digits.
This seems to be a contradiction. Please help me if you have any idea.
With Regards,
Vijay |
If you look at the Cobol forum there was a recent discussion (couple of weeks ago) of the maximum value that can be held in a binary field, and there you'll see that it is possible to get the same range (hint for the search) in a Cobol full-word.
You are not quite accurate about the DB2. It can sometimes successfully contain 10 digits, sometimes not. Try +2147483649. Try +9999999999. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
a binary fullword will hold a value from -2**31 to +2**31 aka -2147483648 to +2147483648
which are 10 digits, but there is gotcha the first digit goes up to 2
a cobol s9(10) expects to hold 10 digits numbers between 0 and 9999999999
so, carry on Your conclusions!
the cobol architecture will prevent in this case full use of a fixed bin 31 ( like PL/1 does ) |
|
Back to top |
|
|
|