Pregunta

I parse an xml-document with dom, which includes tags like this:

<edge cost="2.811138559374119e+02">0</edge>

Now I saved the Number as a String. How can I save it as a double, so that I can use the number for further calculations? How does this work with "e+0x" ?

Thanks for your advice.

¿Fue útil?

Solución

Just use Double.parseDouble().

Live example: http://ideone.com/1NMDtL.

FYI, this is a form of scientific notation.

Otros consejos

This is scientific notation, it means 2.811138559374119 × 10+02 (the AeB means A × 10B).

Use Double.parseDouble() :

String str = "2.811138559374119e+02";
double val = Double.parseDouble(str);
// val is 281.1138559374119 double
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top