on 02-09-2011 5:59 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Use standard function formatNumber
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.