Added long to double typecast for division ops. 75/10775/1
authorLukas Sedlak <lsedlak@cisco.com>
Thu, 4 Sep 2014 13:13:48 +0000 (15:13 +0200)
committerLukas Sedlak <lsedlak@cisco.com>
Thu, 4 Sep 2014 13:13:48 +0000 (15:13 +0200)
Added long to double typecast in addDuration method to increase precision after division operations.

Change-Id: I4cba5661c9b634db86d25b2286e7f9cd4fa84b6c
Signed-off-by: Lukas Sedlak <lsedlak@cisco.com>
common/util/src/main/java/org/opendaylight/yangtools/util/DurationStatsTracker.java

index 45ebd01306ced758a627bf0ad8eceac54b9f530d..21690c2864e705817a6245dc2c9ec98ac1b21675 100644 (file)
@@ -46,7 +46,7 @@ public class DurationStatsTracker {
         long newTotal = currentTotal + 1;
 
         // Calculate moving cumulative average.
-        double newAve = currentAve * currentTotal / newTotal + duration / newTotal;
+        double newAve = currentAve * (double)currentTotal / (double)newTotal + (double)duration / (double)newTotal;
 
         averageDuration.compareAndSet(currentAve, newAve);
         totalDurations.compareAndSet(currentTotal, newTotal);