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

Functionality for converting exponential to Numerix format


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pavanchandana

New User


Joined: 05 Sep 2008
Posts: 15
Location: Hyderabad

PostPosted: Tue Jun 25, 2013 2:57 pm
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Jun 25, 2013 3:09 pm
Reply with quote

Can you show input and output datatype and move statement with code tags on?
Back to top
View user's profile Send private message
pavanchandana

New User


Joined: 05 Sep 2008
Posts: 15
Location: Hyderabad

PostPosted: Tue Jun 25, 2013 3:14 pm
Reply with quote

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
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Tue Jun 25, 2013 3:46 pm
Reply with quote

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
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Jun 25, 2013 4:47 pm
Reply with quote

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
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Tue Jun 25, 2013 6:51 pm
Reply with quote

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
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Tue Jun 25, 2013 7:04 pm
Reply with quote

It is sad but true that inconsistencies are always been imposed to be fixed in MF icon_sad.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Jun 25, 2013 7:04 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts InfoSphere OPTIM CSV ouput vs DSNTIUA... IBM Tools 3
Search our Forums:

Back to Top