cancel
Showing results for 
Search instead for 
Did you mean: 

1.0000000000000000E+00 convert into float value

Former Member
0 Kudos

Hi all,

I am getting the 1.0000000000000000E+00 value from idoc i need to convert into float format value with xi graphical mapping.

please help to me

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Swathi,

It is evident that you may get values with different Exponents like E+ or E-.

To convert from Scientific number format to float format please use this below code in your UDF:

Double.Parse("1.000000000000E+00", System.Globalization.NumberStyles.Float);

or

Double.Parse("1.000000000000E-4", System.Globalization.NumberStyles.Float);

You can pass this string "1.000000000000E+00" as argument.

Or If your output of the value is String then use this code:

int val = new BigDecimal(stringValue).intValue();

Regards

Praveen K

Former Member
0 Kudos

But formatnum function has a problem, the number of places of decimal has to be hardcoded in the parameter of the formatnum function, and therefore there are chances of redundant zeroes at the end of the number obtained as output.

BUT THE OUTPUT OF MY CODE DOESN'T HAVE SUCH A PROBLEM.

<DON'T WRITE IN CAPITAL LETTERS <READ RULES OF ENGAGEMENT>

THANKS

BISWAJIT

Edited by: Prateek Raj Srivastava on Mar 13, 2011 7:18 AM

matt
Active Contributor
0 Kudos

If you don't like that fact that someone doesn't give you points, stop asking their questions. The purpose of these forums is to help one another, not acrue points.

Former Member
0 Kudos

Hi,

Thanks for your reply

when i will use these funtion i am getting error "Exception:[java.lang.StringIndexOutOfBoundsException: String index out of range: -19] ". I am using Execution of type "All values of queue".

shall we can solve this issue?

Former Member
0 Kudos

Hi Swathi,

Use the FormatNumber function from Artihmatic functions.

This easily converts the Format of 1.0000E+01 or 1.000000E-01 kind of numbers to 1.00 or 0.10

You can modify the parameter of the FormatNumber function and get the required format in the target side.

Regards,

Aravind

Former Member
0 Kudos

hi Swathi

No need to write a UDF . Use Arithmetic function FormatNum and pass ####.##### (upto however many decimals you need).

stefan_grube
Active Contributor
0 Kudos

Use standard function formatNumber

Former Member
0 Kudos

You have to write a simple UDF that takes the value as input string and converts it into float:

You just create an UDF that takes a single string array as input, say s[], and it has one ResultList item named result as output to send the output to the target field.

This single string array s[] will contain the value coming from the incoming field i.e { s[0]= "1.0000000000000000E+00"}

I HAVE TESTED THE CODE, IT WORKS ABSOLUTELY FINE.

THE ENTIRE CODE IS AS FOLLOWS...SIMPLY COPY PASTE IT . NO NEED TO CHANGE ANYTHING:)

int index=s[0].indexOf("E");

String exp=s[0].substring(index+2,s.length());

int exp1=Integer.parseInt(exp.substring(0,1));

int exp2=Integer.parseInt(exp.substring(1,2));

int exponen= exp1*10+exp2;

double power=Math.pow(10,exponen);

String bb=s[0].substring(0,index);

double b=Double.parseDouble(bb);

long res=(long)(b*power);

result.addValue(res);

<REMIOVED BY MODERATOR>

CHEERS

BISWAJIT

Edited by: 007biswa on Feb 9, 2011 8:38 AM

Edited by: Prateek Raj Srivastava on Mar 13, 2011 7:19 AM