From 1bee79789d8ffb743562f3d9cc05b444f7f0e918 Mon Sep 17 00:00:00 2001 From: Joshua Kissoon Date: Wed, 7 May 2014 10:07:12 +0530 Subject: [PATCH] Statistician - Formatted the double returned by averages --- src/kademlia/Statistician.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/kademlia/Statistician.java b/src/kademlia/Statistician.java index ed270ae..c033656 100644 --- a/src/kademlia/Statistician.java +++ b/src/kademlia/Statistician.java @@ -1,5 +1,7 @@ package kademlia; +import java.text.DecimalFormat; + /** * Class that keeps statistics for this Kademlia instance. * @@ -111,13 +113,17 @@ public class Statistician * * @return The average time */ - public long averageContentLookupTime() + public double averageContentLookupTime() { - return this.totalContentLookupTime / this.numContentLookups; + double avg = (double) this.totalContentLookupTime / (double) this.numContentLookups; + DecimalFormat df = new DecimalFormat("#.00"); + return new Double(df.format(avg)); } public double averageContentLookupRouteLength() { - return (double) ((double) this.totalRouteLength / (double) this.numContentLookups); + double avg = (double) ((double) this.totalRouteLength / (double) this.numContentLookups); + DecimalFormat df = new DecimalFormat("#.00"); + return new Double(df.format(avg)); } }