Class NumberContext

java.lang.Object
org.ojalgo.type.context.FormatContext<Comparable<?>>
org.ojalgo.type.context.NumberContext
All Implemented Interfaces:
TypeContext<Comparable<?>>

public final class NumberContext extends FormatContext<Comparable<?>>

Think of this as a MathContext that specifies both precision and scale. Numeric data types (non-integers) in databases are specified using precision and scale. While doing maths the precision is all that matters, but before sending a number to a database, or printing/displaying it, rounding to a specified scale is desirable.

The enforce methods first enforce the precision and then set the scale. It is possible that this will create a number with trailing zeros and more digits than the precision allows. It is also possible to define a context with a scale that is larger than the precision. This is NOT how precision and scale is used with numeric types in databases.

  • Field Details

    • DEFAULT_MATH

      private static final MathContext DEFAULT_MATH
    • DEFAULT_SCALE

      private static final int DEFAULT_SCALE
      See Also:
    • DEFAULT_STYLE

      private static final NumberStyle DEFAULT_STYLE
    • myEpsilon

      private final double myEpsilon
    • myMathContext

      private final MathContext myMathContext
    • myRoundingFactor

      private final double myRoundingFactor
    • myScale

      private final int myScale
    • myZeroError

      private final double myZeroError
  • Constructor Details

  • Method Details