×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Java
Posted by: Ellirabeth Dzhurko
Added: Sep 20, 2017 1:37 PM
Views: 6
Tags: no tags
  1.     /**
  2.      * Round a double value, number of decimals depends on the roundingFactor.
  3.      * e.g. round(10.1233, 100) returns 10.12
  4.      *
  5.      * @param value          value
  6.      * @param roundingFactor roundingFactor
  7.      * @return new rounded value
  8.      */
  9.     public static double roundResult(double value, int roundingFactor) {
  10.         double doubleRounded = Math.round(value * roundingFactor);
  11.         return doubleRounded / roundingFactor;
  12.     }