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
 

 

COBOL query - Variable

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
senthamizh

New User


Joined: 27 Apr 2009
Posts: 22
Location: mumbai

PostPosted: Sat Feb 06, 2016 1:41 am    Post subject: COBOL query - Variable
Reply with quote

Hi,

in my program i am fetching the rate from a table.When i check tha table it is holding value of 17.38.but when i put display for host variable it is showing 17.37.This column is nullable column.

my query is
select ifnull(RATE,1 )
into :ratef
from table1.

RATE is defined as FLOAT.

i am not sure how 17.37 is retived. I have defined Host variable as RATE usasge comp2.

Can some one help me on this.How the table value is subracted by .01.
Back to top
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7908
Location: Bellevue, IA

PostPosted: Sat Feb 06, 2016 2:14 am    Post subject: Reply to: COBOL query - Variable
Reply with quote

The value 17.38, expressed as a D-type floating point value in Assembler, is X'42116147AE147AE1' so it is obviously not a precise value in hexadecimal. The most likely explanation for what you are seeing is that COBOL and DB2 handle floating point values slightly differently, and you have found one of those values where the difference is apparent.

Unfortunately, this is one of the drawbacks to using floating point values, and you need to find out how your site handles such discrepancies. They can happen at any time for any value and there's not a lot that can be done about the difference, other than change the data base to not use floating point values.
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7225

PostPosted: Sat Feb 06, 2016 2:14 am    Post subject: Reply to: COBOL query - Variable
Reply with quote

You'd better show your code. If you DISPLAY a COMP-2 you're not going to get the output you have shown.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7908
Location: Bellevue, IA

PostPosted: Sat Feb 06, 2016 3:31 am    Post subject:
Reply with quote

To add to Bill's comment, when I create a COMP-2 variable and move 17.38 to it for DISPLAY, I get
Code:
 .17379999999999999E 02
If this is why you think the value is 17.37, you need to move over to the Beginner's and Students forum instead of this one.
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm
No new posts Regarding COBOL Stored Procedure opti... selvamsrinivasan85 DB2 4 Fri Nov 04, 2016 8:57 pm
No new posts Two Selects in a single select query Rohit Umarjikar DB2 1 Fri Nov 04, 2016 8:46 pm
No new posts COBOL Version 6.1 Virendra Shambharkar COBOL Programming 5 Tue Nov 01, 2016 11:24 am


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