Class BigDecimalMathExtension


  • public class BigDecimalMathExtension
    extends java.lang.Object
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.math.BigDecimal round​(java.math.BigDecimal value, java.math.MathContext mathContext)
      Rounds value according to the math context.
      static java.math.BigDecimal toDegrees​(java.math.BigDecimal radians, java.math.MathContext mathContext)
      Converts from radians to degrees using a cached PI constant of correct scale.
      static java.math.BigDecimal toRadians​(java.math.BigDecimal degrees, java.math.MathContext mathContext)
      Converts from degrees to radians using a cached PI constant of correct scale.
      • Methods inherited from class java.lang.Object

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

      • round

        public static java.math.BigDecimal round​(java.math.BigDecimal value,
                                                 java.math.MathContext mathContext)
        Rounds value according to the math context.

        Fixes a bug in BigDecimal.round(MathContext)

        Parameters:
        value - The value to round.
        mathContext - The MathContext to use.
        Returns:
        The rounded value.
      • toRadians

        public static java.math.BigDecimal toRadians​(java.math.BigDecimal degrees,
                                                     java.math.MathContext mathContext)
        Converts from degrees to radians using a cached PI constant of correct scale.
        Parameters:
        degrees - An angle in degrees.
        mathContext - The MathContext to use.
        Returns:
        An angle in radians.
      • toDegrees

        public static java.math.BigDecimal toDegrees​(java.math.BigDecimal radians,
                                                     java.math.MathContext mathContext)
        Converts from radians to degrees using a cached PI constant of correct scale.
        Parameters:
        radians - An angle in radians.
        mathContext - The MathContext to use.
        Returns:
        An angle in degrees.