Converting exponential notation to integer

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
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

I assume that this cannot be done at source and/or target?
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

Failing that - doesn't the E represent the number of places to move the decimal?

So using the E as a delimiter split your values into the digit (the first part) and the exponential and just multiply them out?
6.4443433E7 = 6.4443433*10^7
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The data cannot be correctly read in at the source (thanks to an excel source file with 600K rows and the way that the unstructured data stage works).
The "E" is indeed base 10 exponential; I thought about the mathematical approach and think that it will take longer than the string approach.

Code: Select all

svTrimNoLeading[1,LEN(svTrimNoLeading)-2]*(10**Right(svTrimNoLeading,1)
I should add that the output value is a string column, so the computation above still needs to be converted from a decimal/numeric to a string using some method such as the embedded trims above.

Addendum - I just ran a test and the original solution is faster.
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

So you cannot just convert to dfloat to decimal, then decimal to string and suppress zeros?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

The decimal-to-string conversion just has the "fix_zero" option to allow a 0 value, but no suppress zeroes.
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

When did this happen. Did they remove the "suppress_zero" option?
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

I can't find it in my documentation for the DecimalToString.
priyadarshikunal
Premium Member
Premium Member
Posts: 1735
Joined: Thu Mar 01, 2007 5:44 am
Location: Troy, MI

Post by priyadarshikunal »

Did you try AsInteger()? I think it works with dfloat too. Truncates the mantissa (decimal part) though.
Priyadarshi Kunal

Genius may have its limitations, but stupidity is not thus handicapped. :wink:
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Yes, I did try AsInteger(). It does work with dfloat, but converts to a binary representation and thus isn't feasible in this context.
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

ArndW wrote:I can't find it in my documentation for the DecimalToString.
I am pretty sure its still there. It would be "suppress_zero"
ArndW
Participant
Posts: 16318
Joined: Tue Nov 16, 2004 9:08 am
Location: Germany
Contact:

Post by ArndW »

Cool - the statement is now

Code: Select all

DecimalToString(DFloatToDecimal(svtest),"suppress_zero")

and that is faster and easier to understand.
ShaneMuir
Premium Member
Premium Member
Posts: 508
Joined: Tue Jun 15, 2004 5:00 am
Location: London

Post by ShaneMuir »

ArndW wrote:that is faster and easier to understand. ...
Excellent! And good to know that its faster.
Post Reply