View previous topic :: View next topic
|
Author |
Message |
pavanchandana
New User
Joined: 05 Sep 2008 Posts: 15 Location: Hyderabad
|
|
|
|
Hi All,
Could some one help me with any functionality for converting exponential to Numerix format.
I am getting the input like -1.302e+06. If I handle it throw numeric data types, the job is failing with S0C-7 error.
could you please let me know the COBOL equivalent declartion for the above exponential values.
Thanks in advance
Pavan |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
Can you show input and output datatype and move statement with code tags on? |
|
Back to top |
|
|
pavanchandana
New User
Joined: 05 Sep 2008 Posts: 15 Location: Hyderabad
|
|
|
|
I have coded the logic to handle -1.30200 but today I got the value as -1.302e+06 in my input. I want to handle these exceptional cases as well. I did some research on this and found that we can declare the data type with E but I feel it wont work with the actual numeric values which are not having e+ in it.
These values are passed thru XML
Please help me |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
pavanchandana wrote: |
Hi All,
Could some one help me with any functionality for converting exponential to Numerix format.
I am getting the input like -1.302e+06. If I handle it throw numeric data types, the job is failing with S0C-7 error.
could you please let me know the COBOL equivalent declartion for the above exponential values.
Thanks in advance
Pavan |
Read about external floating-point items. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
From what you have posted so far, your question cannot be answered. COBOL has two external floating point data types, COMP-1 and COMP-2, and which one you use depends upon the input data.
However, I suspect your problem is not with external floating point values, but with input data coming in as USAGE DISPLAY but having the exponent in the display format. What is the difference? -1.3206e+06 is in display format; the COMP-1 equivalent would be X'C613E048'. If this is the case, you will need to write your own code to determine how to computer the value including the exponent. Or, if you do not need the numeric value, just treat the data as alphanumeric text (PIC X). |
|
Back to top |
|
|
Akatsukami
Global Moderator
Joined: 03 Oct 2009 Posts: 1788 Location: Bloomington, IL
|
|
|
|
Robert Sample wrote: |
From what you have posted so far, your question cannot be answered. COBOL has two external floating point data types, COMP-1 and COMP-2, and which one you use depends upon the input data. |
I think that that may not be the case.
COMP-1 and COMP-2 are internal floating-point formats. An external floating point number would have usage DISPLAY and picture -mantissaE+exponent.
Re-reading this thread, I believe that Pavan's problem is that the generator of the XML (Excel, perhaps) is not providing a consistent format for the data. As you say, he will have have to write some code to determine the format and handle it accordingly. |
|
Back to top |
|
|
Pandora-Box
Global Moderator
Joined: 07 Sep 2006 Posts: 1592 Location: Andromeda Galaxy
|
|
|
|
It is sad but true that inconsistencies are always been imposed to be fixed in MF |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Yes, I got internal and external mixed up. Trying too much multitasking, I suspect.
pavanchandana, you need to review the incoming data. If it is all one format (-1.3206e+06 for example) then you can handle the data via a PIC clause in COBOL. If there are multiple formats (1.27e+03 as well as -1.3206e+06 for example -- where the data values are not byte-for-byte aligned) then you will need to either (a) get the source to send you data in only one format, or (b) write your own code to determine the numeric value of the data you are getting. Oh, and your title is very misleading -- exponential data is numeric, just not numeric in an easily used format. |
|
Back to top |
|
|
|