Class Rounder


  • public abstract class Rounder
    extends java.lang.Object
    Provides round numbers. Static instances are provided for rounding numbers to be used in a linear or a logarithmic context.
    Since:
    18 Nov 2005
    Author:
    Mark Taylor
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static Rounder LINEAR
      Number rounder for linear scaling.
      static Rounder LOG
      Number rounder for logarithmic scaling.
      static Rounder TIME_SECOND
      Number rounder for time intervals in seconds.
    • Constructor Summary

      Constructors 
      Constructor Description
      Rounder()  
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      abstract double nextDown​(double value)
      Returns the next round number smaller than the given value.
      abstract double nextUp​(double value)
      Returns the next round number larger than the given value.
      abstract double round​(double value)
      Returns a round number near the given value.
      • Methods inherited from class java.lang.Object

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

      • LINEAR

        public static final Rounder LINEAR
        Number rounder for linear scaling. All values are >0.
      • LOG

        public static final Rounder LOG
        Number rounder for logarithmic scaling. All values are >1.
      • TIME_SECOND

        public static final Rounder TIME_SECOND
        Number rounder for time intervals in seconds. All values are >0.
    • Constructor Detail

      • Rounder

        public Rounder()
    • Method Detail

      • round

        public abstract double round​(double value)
        Returns a round number near the given value.
        Parameters:
        value - input value
        Returns:
        round number near value
      • nextUp

        public abstract double nextUp​(double value)
        Returns the next round number larger than the given value.
        Parameters:
        value - input value
        Returns:
        round number a bit larger than value
      • nextDown

        public abstract double nextDown​(double value)
        Returns the next round number smaller than the given value.
        Returns:
        value input value