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

DB2 FLOAT precision


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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
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

Global Moderator


Joined: 21 Sep 2010
Posts: 3048
Location: NYC,USA

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

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

Active Member


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

PostPosted: Fri Jul 15, 2016 11:20 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Sat Jul 16, 2016 3:22 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
This topic is locked: you cannot edit posts or make replies. JCL to convert float decimal into rea... JCL & VSAM 3
No new posts Comparing a float value to a charecte... DB2 5
No new posts Issue in calling DB2 SP from GUI, los... DB2 1
No new posts Changing the precision of a comp3 field DFSORT/ICETOOL 2
No new posts How to convert Char to Float DFSORT/ICETOOL 5
Search our Forums:

Back to Top