Page 1 of 1
Convert fields containing exponential values to decimal
Posted: Tue Apr 10, 2007 5:46 am
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.
Posted: Tue Apr 10, 2007 7:30 am
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?
Posted: Tue Apr 10, 2007 12:57 pm
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.
Posted: Wed Apr 11, 2007 11:41 pm
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.
Posted: Thu Apr 12, 2007 2:07 am
by ray.wurlod
No. Read my third paragraph again.
Posted: Thu Apr 12, 2007 3:20 am
by sjordery
ray,
I have played with the precession and scale figures but I didnt get the result.
any idea??
Posted: Thu Apr 12, 2007 2:26 pm
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?