How to correctly display nanotim in the second transformation

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();

//algorithm code removed for simplicity this all functions correctly


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?

, , .

+4
2

, : DecimalFormat

System.out.println("solution Time : " + new DecimalFormat("#.##########").format(seconds) + " Seconds");
+8
System.out.format("solution Time : %f Seconds", seconds);

, .

+5

All Articles