Decimal values getting expanded

Post questions here relative to DataStage Enterprise/PX Edition for such areas as Parallel job design, Parallel datasets, BuildOps, Wrappers, etc.

Moderators: chulett, rschirm, roy

Post Reply
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Decimal values getting expanded

Post by mac4rfree85 »

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!!!!
Mac4rfree
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

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.
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Post by mac4rfree85 »

So, Ray there is no solution to this problem?

Thanks!!!!
Mac4rfree
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

Of course there is! :wink:

1. Get a Premium account so you can read Ray's reply in its entirety.
2. Stop using Float as a data type.
-craig

"You can never have too many knives" -- Logan Nine Fingers
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Post by mac4rfree85 »

First one,yes i am working on it. :)

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. :)

Thanks !!!!!
Last edited by mac4rfree85 on Thu Jul 05, 2012 8:58 am, edited 1 time in total.
Mac4rfree
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

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?
chulett
Charter Member
Charter Member
Posts: 43085
Joined: Tue Nov 12, 2002 4:34 pm
Location: Denver, CO

Post by chulett »

mac4rfree85 wrote:When we used decimal, decimal values are not getting inserted. Hence only we have used float.
I too would be curious what this means. :?
-craig

"You can never have too many knives" -- Logan Nine Fingers
mac4rfree85
Participant
Posts: 126
Joined: Thu Jul 01, 2010 11:39 pm

Post by mac4rfree85 »

The data was not getting inserted properly.

For an example, if data was 8.56, it was getting inserted as 0000000.

Not sure why, but with float, we were somewhat getting (8.5600001).

But now with double, i am getting what i want (8.56)
Mac4rfree
jwiles
Premium Member
Premium Member
Posts: 1274
Joined: Sun Nov 14, 2004 8:50 pm
Contact:

Post by jwiles »

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,
- james wiles


All generalizations are false, including this one - Mark Twain.
Post Reply