Skip to Content
Former Member

# 1.0000000000000000E+00 convert into float value

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

##### Add comment
10|10000 characters needed characters exceeded

### 4 Answers

• Former Member
Feb 09, 2011 at 07:23 AM

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

##### Add comment
10|10000 characters needed characters exceeded
• Feb 09, 2011 at 07:51 AM

Use standard function formatNumber

##### Add comment
10|10000 characters needed characters exceeded
• Former Member
Feb 09, 2011 at 09:13 AM

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

##### Add comment
10|10000 characters needed characters exceeded
• Former Member Former Member

hi Swathi

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

• Former Member
Feb 14, 2011 at 06:25 AM

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

##### Add comment
10|10000 characters needed characters exceeded