Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Converting FLOAT to Readable format

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Wed Jul 27, 2011 6:26 pm    Post subject: Converting FLOAT to Readable format
Reply with quote

In DSNTIAUL, I am trying to unload a float value. When i open the SYSREC file I see values in packed format. I want to know is there any why I can convert the FLOAT values to a readable format while unloading data from the table?
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Wed Jul 27, 2011 6:50 pm    Post subject:
Reply with quote

A visit to the film director's couch? Launching fly, hook and line into the water to try to catch a fish?

Or some other sort of "casting"?
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Wed Jul 27, 2011 6:55 pm    Post subject:
Reply with quote

I tried using Cast function --

When I try to cast it to DECIMAL --> Decimal sign was getting lost.
Also when I am trying to cast it as DECIMAL(10,3) then the decimal part was retained but hardcoding 10,3 will not work for all the cases.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 27, 2011 7:17 pm    Post subject: Reply to: Converting FLOAT to Readable format
Reply with quote

I'm not DB2 literate (and maybe I misunderstood your question), but perhaps (assuming this is COBOL) the following could be adapted for converting Floating Point data to displayable (readable) format?

http://www.ibmmainframes.com/viewtopic.php?p=115071&highlight=#115071

Bill
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Wed Jul 27, 2011 7:21 pm    Post subject:
Reply with quote

COBOL equivalent for FLOAT is COMP-2 .
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2502
Location: Atlanta, Georgia, USA

PostPosted: Wed Jul 27, 2011 8:22 pm    Post subject: Reply to: Converting FLOAT to Readable format
Reply with quote

For COMP-2 (long Floating Point) fields, if it is redefined as a PIC X(08) and moved to WS-PACKED-X (1:8) it should successfully unpack and be readable in WS-DISPLAY-X (1:16).

The same would apply to COMP-1 (short Floating Point), if redefined as PIC X(04) and moved to WS-PACKED-X (1:4).

In an UNPK instruction (MOVE WS-PACKED-V9 TO WS-DISPLAY-V9), each 4-Bit value unpacks with a high-order 'F' zone.

In the link-solution posted, (after the MOVE statement), WS-DISPLAY-X is always left-justified with low-order ZEROS.

Give it a try (although, no guarantees).... icon_wink.gif

Bill
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Wed Jul 27, 2011 9:02 pm    Post subject:
Reply with quote

char(floatcol) will return the scientific notation : 1.57658E-2
it depends on what you call "readable"
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Thu Jul 28, 2011 12:00 pm    Post subject:
Reply with quote

Thanks GuyC... I tried this already... But i want to display it as 0.0157658
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Thu Jul 28, 2011 12:33 pm    Post subject:
Reply with quote

Hi All,

I tried the below code....

Code:

SELECT
DECIMAL(SUBSTR(CHAR(1.023E02),1,LOCATE('E',CHAR(1.023E02))-1),31,18)*POWER(10,INTEGER(SUBSTR(CHAR(1.023E02),LOCATE('E',CHAR(1.023E02))+1,LENGTH(STRIP(CHAR(1.023E02))))))
FROM SYSIBM.SYSDUMMY1 ;


Is there any better way to do this? Also will there be any data problem if I use this?
Back to top
View user's profile Send private message
GuyC

Senior Member


Joined: 11 Aug 2009
Posts: 1278
Location: Belgium

PostPosted: Thu Jul 28, 2011 4:48 pm    Post subject:
Reply with quote

that is exactly the same as casting it to DECIMAL(31,18)
and it will have the same (or worse) problem with numbers outside 1E-15 or 1E+12
Back to top
View user's profile Send private message
gylbharat

Active Member


Joined: 31 Jul 2009
Posts: 565
Location: Bangalore

PostPosted: Thu Jul 28, 2011 6:58 pm    Post subject:
Reply with quote

Thanks GuyC
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Match or compare two files in VB Format anatol DFSORT/ICETOOL 14 Thu Nov 03, 2016 7:41 pm
No new posts Low values Results from VARCHAR FORMAT balaji81_k DB2 10 Thu Oct 20, 2016 1:18 am
No new posts output data in CSV Format janmejay COBOL Programming 8 Sat Oct 15, 2016 2:20 pm
This topic is locked: you cannot edit posts or make replies. output data in CSV Format janmejay DFSORT/ICETOOL 3 Sat Oct 15, 2016 2:16 pm
No new posts Format to pipe delimited with variabl... pshongal SYNCSORT 6 Wed Sep 14, 2016 2:48 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us