سؤال

I am working on implementing a simulated annealing program and part of this involves calculating scores from a .txt file that my java program reads.

1) an input string is read from the user. The longer my input string, the more likely the following exception below occurs

2) the score that is calculated is essentially adding a lot of decimal numbers and I store it in a 'double' variable.

Can someone please advise me why such an exception would occur?

Score from Hill Swap: 0.24874990000000005 After swap... Exception in thread "main" java.lang.NumberFormatException: For input string: "7.92066E-" at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1224)

Thanks very much!

هل كانت مفيدة؟

المحلول

It means that your program is trying to parse the string "7.92066E-" which is not parseable as a Double.

You should check where this string is coming from (the rest of the stack trace should tell you) and make sure that you're not getting invalid data somewhere along the line.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top