View previous topic :: View next topic
|
Author |
Message |
soundarr
New User
Joined: 17 Jan 2008 Posts: 25 Location: Chennai
|
|
|
|
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 |
|
|
soundarr
New User
Joined: 17 Jan 2008 Posts: 25 Location: Chennai
|
|
|
|
-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 |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3053 Location: NYC,USA
|
|
|
|
What is the problem here with DB2? |
|
Back to top |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
|