I have a BFS algorithm for solving 8-puzzles, and one of the requirements of the project is to deduce the amount of time it takes to find a shallow solution.
I use System.nanoTime()to track application runtimes because it solves most of the given puzzles in a second.
The problem I am facing is that I convert mine nanoTimeto seconds, it displays in a strange format.
The following code is used:
final long startTime = System.nanoTime();
final long duration = System.nanoTime() - startTime;
final double seconds = ((double)duration / 1000000000);
System.out.println("Nano time total: " + duration);
System.out.println("solution Time : " + seconds + " Seconds");
This leads to the output:
Nano time total: 916110
solution time : 9.1611E-4 Seconds
I also tried using float to represent values.
- is it anyone who can provide the best way to convert / display, perhaps use the format output operator?
, , .