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

COBOL query - Variable


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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: 8697
Location: Dubuque, Iowa, USA

PostPosted: Sat Feb 06, 2016 2:14 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Sat Feb 06, 2016 2:14 am
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: 8697
Location: Dubuque, Iowa, USA

PostPosted: Sat Feb 06, 2016 3:31 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
Search our Forums:

Back to Top