문제

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.

도움이 되었습니까?

해결책

Just use Double.parseDouble().

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

FYI, this is a form of scientific notation.

다른 팁

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
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top