Decimal values getting expanded
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 126
- Joined: Thu Jul 01, 2010 11:39 pm
Decimal values getting expanded
Hi Guys,
My source is a flat file. My target is a oracle table. The column in question is of metadata Number(22,12) in oracle.
In datastage, i am using the metadata float 22,12.
Now the problem is, in the source file iam getting the value 46.536. But in the oracle table that value is getting inserted as 46.5359993.
Also , the source file having a value 3.608 is getting inserted as 3.60800004.
If i keep a sequential file, it is matching (46.536,3.608).
Can somebody help me out here.
Cheers!!!!
My source is a flat file. My target is a oracle table. The column in question is of metadata Number(22,12) in oracle.
In datastage, i am using the metadata float 22,12.
Now the problem is, in the source file iam getting the value 46.536. But in the oracle table that value is getting inserted as 46.5359993.
Also , the source file having a value 3.608 is getting inserted as 3.60800004.
If i keep a sequential file, it is matching (46.536,3.608).
Can somebody help me out here.
Cheers!!!!
Mac4rfree
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Floating point numbers can not be stored accurately in computers; this relates to the fixed size of the binary mantissa and exponent. Review the relevant IEEE standards to understand more. Meanwhile, try using Decimal rather than Float as the data type.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
-
- Participant
- Posts: 126
- Joined: Thu Jul 01, 2010 11:39 pm
-
- Participant
- Posts: 126
- Joined: Thu Jul 01, 2010 11:39 pm
First one,yes i am working on it. ![Smile :)](./images/smilies/icon_smile.gif)
When we used decimal, decimal values are not getting inserted. Hence only we have used float. So can you suggest which metadata needs to be used for a decimal value.
The issue is fixed. changed the metadata from Float to Double.![Smile :)](./images/smilies/icon_smile.gif)
Thanks !!!!!
![Smile :)](./images/smilies/icon_smile.gif)
When we used decimal, decimal values are not getting inserted. Hence only we have used float. So can you suggest which metadata needs to be used for a decimal value.
The issue is fixed. changed the metadata from Float to Double.
![Smile :)](./images/smilies/icon_smile.gif)
Thanks !!!!!
Last edited by mac4rfree85 on Thu Jul 05, 2012 8:58 am, edited 1 time in total.
Mac4rfree
As stated several times before - avoid floating point. Your data in the sequential source is in decimal format and should be read, and stored, as such. Sequential files can read decimal data, so if you are not getting values then there is a problem in the column definitions that you should correct.
What have tried with reading decimal values and what exactly has happened?
What have tried with reading decimal values and what exactly has happened?
-
- Participant
- Posts: 126
- Joined: Thu Jul 01, 2010 11:39 pm
FYI...Double is still a floating point data type, so you are at risk of seeing the same type of issue arise again.
If you were seeing 0 inserted instead of the actual values when the source was defined as a decimal, that indicated that the value was not imported most likely due to some formatting issues, such as leading spaces (which could be the case with a fixed-width, right-justified column). Examine your source data to see what it actually contains. You may need to instead import it as char or varchar and then clean it and convert to decimal within a transformer instead.
Regards,
If you were seeing 0 inserted instead of the actual values when the source was defined as a decimal, that indicated that the value was not imported most likely due to some formatting issues, such as leading spaces (which could be the case with a fixed-width, right-justified column). Examine your source data to see what it actually contains. You may need to instead import it as char or varchar and then clean it and convert to decimal within a transformer instead.
Regards,
- james wiles
All generalizations are false, including this one - Mark Twain.
All generalizations are false, including this one - Mark Twain.