Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 23
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: 8553
Location: Dubuque, Iowa, USA

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: 7312

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: 8553
Location: Dubuque, Iowa, USA

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
No new posts Restart logic by using cursor name in... Twinkle22 Mainframe Interview Questions 1 Wed Jul 29, 2020 11:26 am
No new posts Determine what library member is in, ... mdwait JCL & VSAM 9 Thu Jul 23, 2020 3:02 am
No new posts COBOL Developers Perspectives on Soft... achakarov COBOL Programming 4 Sat Jul 18, 2020 1:26 am
No new posts CALL statement in COBOL for VSE Kirthishine COBOL Programming 3 Fri Jun 26, 2020 12:12 pm
No new posts Mainframe ISPREDIT Macro query upendrasri TSO/ISPF 3 Wed May 27, 2020 1:12 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us