Class Rounding


  • public class Rounding
    extends java.lang.Object
    A class for performing the rounding of a number in various ways for various applications.
    Author:
    Gianni Amati, Ben He, Vassilis Plachouras, Craig Macdonald
    • Constructor Summary

      Constructors 
      Constructor Description
      Rounding()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static double round​(double val, int places)
      Round a double alue to a specified number of decimal places.
      static float round​(float val, int places)
      Round a float value to a specified number of decimal places.
      static java.lang.String toString​(double d, int place)
      Rounds to place digits and transforms the double number d to a string for printing
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Rounding

        public Rounding()
    • Method Detail

      • toString

        public static java.lang.String toString​(double d,
                                                int place)
        Rounds to place digits and transforms the double number d to a string for printing
        Parameters:
        d - double the number to transform
        place - int the number of decimal digits
        Returns:
        String the string representing the rounded number.
      • round

        public static double round​(double val,
                                   int places)
        Round a double alue to a specified number of decimal places.
        Parameters:
        val - the value to be rounded.
        places - the number of decimal places to round to.
        Returns:
        val rounded to places decimal places.
        Since:
        1.1.0
      • round

        public static float round​(float val,
                                  int places)
        Round a float value to a specified number of decimal places. Calls round(double,int) internally.
        Parameters:
        val - the value to be rounded.
        places - the number of decimal places to round to.
        Returns:
        val rounded to places decimal places.
        Since:
        1.1.0