Skip to main content
Announcements
A fresh, new look for the Data Integration & Quality forums and navigation! Read more about what's changed.
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

When i try to convert from bigdecimal to double , it gets converted to exponential automatically. how to avoid it.

Im trying to convert this bigdecimal "456456456456456" to double using this expression in tmap

row1.amount!=null?row1.amount.doubleValue():0 . I get 4.56456456456456E14 as the result . what should i do convert as it is to 456456456456456 .

Labels (2)
1 Solution

Accepted Solutions
Anonymous
Not applicable
Author

If you are writing to a file, change your column to a String and use this code to convert it....

row1.amount!=null?row1.amount.toPlainString():"0"

View solution in original post

9 Replies
Anonymous
Not applicable
Author

The numbers are the same. It is just represented using scientific notation. Are you printing this out? Do you need this printed without the scientific notation?

fdenis
Master

format your output if you do not want exponential in result. it's the Double store methode.
Anonymous
Not applicable
Author

Rhall,

 

When i output in file using tfileoutputdelmited , i get the exponential value . i need it in the same format without exponential .

Anonymous
Not applicable
Author

Im not sure how to do that . Can you help me

Anonymous
Not applicable
Author

If you are writing to a file, change your column to a String and use this code to convert it....

row1.amount!=null?row1.amount.toPlainString():"0"
Anonymous
Not applicable
Author

Thanks rhall , Is there any way after reading the file we could chenage that type of the field  to bigdecimal or double ?

Anonymous
Not applicable
Author

If you are reading a flat file ALL fields are essentially Strings. The Talend components will use the schema you create to convert on reading the data

Anonymous
Not applicable
Author

But what if I dont want to change the data type of the field to string. Is there any other alternative for this?

Anonymous
Not applicable
Author

If you are writing to a flat file, the conversion of your column data is implicitly converted to a String. Flat file data is a String. If you are loading to a target which is able to comprehend different data types, then the formatting of those types will be configured within the target.