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
 

 

DB2 FLOAT precision

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

New User


Joined: 17 Jan 2008
Posts: 25
Location: Chennai

PostPosted: Fri Jul 15, 2016 9:47 pm    Post subject: DB2 FLOAT precision
Reply with quote

Hi All,

I am populating a FLOAT column with -99.9634495 via PL1 program and check in the table, it is stored as -9.9963449499999999E+01. I try the same via SPUFI/file manager, same result.

When I select the value from SPUFI, I see -99.9634495 whereas File manager shows -9.9963449499999999E+01.

Please suggest if there is any way to store it without the padded 9s in the table?

Thanks
Soundar
Back to top
View user's profile Send private message

soundarr

New User


Joined: 17 Jan 2008
Posts: 25
Location: Chennai

PostPosted: Fri Jul 15, 2016 10:51 pm    Post subject:
Reply with quote

-99.9634495 is just an example. Issue(padded 9s) happens on some values. I couldn't find any pattern. Want to know if this is a limitation with DB2 FLOAT and if it can be handled in any way.
Back to top
View user's profile Send private message
Rohit Umarjikar

Senior Member


Joined: 21 Sep 2010
Posts: 1609
Location: NY,USA

PostPosted: Fri Jul 15, 2016 11:09 pm    Post subject:
Reply with quote

What is the problem here with DB2?
Back to top
View user's profile Send private message
steve-myers

Active User


Joined: 30 Nov 2013
Posts: 461
Location: The Universe

PostPosted: Fri Jul 15, 2016 11:20 pm    Post subject:
Reply with quote

I have no idea how DB2 stores floating point values. However, what you are describing is generic to floating point arithmetic in computers, and converting floating point values from decimal to binary and back to decimal. In general, it is not possible to convert something like 99.999 to an exact binary representation, and convert it back to 99.9990000. There are some exceptions. 99.50000 will convert exactly, and it should convert back to 99.5000000. However there is no “exact” conversion for most decimal fractions.
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 Jul 16, 2016 3:22 am    Post subject:
Reply with quote

Quote:
Want to know if this is a limitation with DB2 FLOAT and if it can be handled in any way.
This is because of how computers handle floating point, as otherwise stated, and there is nothing you can do about it. For example, 0.1 is an infinite repeating fraction in binary and hence CANNOT be precisely represented in floating point. If the issue is important, don't use floating point.
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
This topic is locked: you cannot edit posts or make replies. JCL to convert float decimal into rea... polymathtarun JCL & VSAM 3 Sun May 15, 2016 9:57 pm
No new posts Comparing a float value to a charecte... ravindra.vadali DB2 5 Mon Sep 15, 2014 8:28 pm
No new posts Issue in calling DB2 SP from GUI, los... rexx77 DB2 1 Thu Nov 14, 2013 6:32 pm
No new posts Changing the precision of a comp3 field razesh84 DFSORT/ICETOOL 2 Tue Jan 08, 2013 3:06 pm
No new posts How to convert Char to Float Lingam D DFSORT/ICETOOL 5 Wed Oct 03, 2012 8:08 pm


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