Convert fields containing exponential values to decimal

A forum for discussing DataStage<sup>®</sup> basics. If you're not sure where your question goes, start here.

Moderators: chulett, rschirm, roy

Post Reply
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

Convert fields containing exponential values to decimal

Post by sjordery »

Hi all,
Please give me a solution regarding this.

I have a file containg values as below

real_daily_return
--------------------
-5.41114562-e05
-4.98887625-e03
---------------------

I want to convert this data having double data type to data having decimal datatype.

This works fine for those numbers with an exponent less than 5 e.g. -1.09909222273045E-03.

Those with an exponent of 5 remain unconverted e.g. -5.41150924939712E-05

So can you suggest me what is the problem here.
DSguru2B
Charter Member
Charter Member
Posts: 6854
Joined: Wed Feb 09, 2005 3:44 pm
Location: Houston, TX

Post by DSguru2B »

How are you converting them to decimal, as in what function are you using?
What is the precision and scale of your target decimal field?
Creativity is allowing yourself to make mistakes. Art is knowing which ones to keep.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

They ARE converted; the View Data mechanism converts them back to scientific notation if they are very small or very large.

Try writing to a database table with the column specified as Decimal with sufficiently large precision and scale.

When writing to a text file (recall that text files don't have data types, only text) try experimenting with the precision and scale figures. However, I believe there's an inbuilt rule to convert to scientific notation when there are four or more zeroes immediately following the decimal place.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

Post by sjordery »

Hi,

Both my source and target is sequential file.
For the source I have defined that partucular column as double
and
for the target I have defined that column as decimal.
up to 4 th exponential it is working fine.

Ray,

Can you suggest me for more than 4th exponential what scentific notation I should use here.
Is it applicable for both sequential file and database table.
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

No. Read my third paragraph again.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
sjordery
Premium Member
Premium Member
Posts: 202
Joined: Thu Jun 08, 2006 5:58 am

Post by sjordery »

ray,
I have played with the precession and scale figures but I didnt get the result.
any idea??
ray.wurlod
Participant
Posts: 54607
Joined: Wed Oct 23, 2002 10:52 pm
Location: Sydney, Australia
Contact:

Post by ray.wurlod »

ray.wurlod wrote:I believe there's an inbuilt rule to convert to scientific notation when there are four or more zeroes immediately following the decimal place.
What part of that was unclear?
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Post Reply