Package com.ibm.icu.math

Examples of com.ibm.icu.math.MathContext


//#endif

    public void testJB4971()
    {
        DecimalFormat decfmt = new DecimalFormat();
        MathContext resultICU;

        MathContext comp1 = new MathContext(0, MathContext.PLAIN);
        resultICU = decfmt.getMathContextICU();
        if ((comp1.getDigits() != resultICU.getDigits()) ||
            (comp1.getForm() != resultICU.getForm()) ||
            (comp1.getLostDigits() != resultICU.getLostDigits()) ||
            (comp1.getRoundingMode() != resultICU.getRoundingMode()))
        {
            errln("ERROR: Math context 1 not equal - result: " + resultICU.toString() +
                " / expected: " + comp1.toString());
        }

        MathContext comp2 = new MathContext(5, MathContext.ENGINEERING);
        decfmt.setMathContextICU(comp2);
        resultICU = decfmt.getMathContextICU();
        if ((comp2.getDigits() != resultICU.getDigits()) ||
            (comp2.getForm() != resultICU.getForm()) ||
            (comp2.getLostDigits() != resultICU.getLostDigits()) ||
            (comp2.getRoundingMode() != resultICU.getRoundingMode()))
        {
            errln("ERROR: Math context 2 not equal - result: " + resultICU.toString() +
                " / expected: " + comp2.toString());
        }

//#if defined(FOUNDATION10) || defined(J2SE13) || defined(J2SE14)
//#else
View Full Code Here


     * @draft ICU 4.2
     * @provisional This API might change or be removed in a future release.
     */
    public void setMathContext(java.math.MathContext newValue)
    {
        mathContext = new MathContext(newValue.getPrecision(),
                                      MathContext.SCIENTIFIC,
                                      false,
                                      (newValue.getRoundingMode()).ordinal()
                                      );
    }
View Full Code Here

            MathContext.ROUND_UNNECESSARY, MathContext.ROUND_UP};

        public Object[] getTestObjects()
        {
            int objectCount = forms.length * rounds.length;
            MathContext contexts[] = new MathContext[objectCount];
            int i = 0;
           
            for (int f = 0; f < forms.length; f += 1) {
                for (int r = 0; r < rounds.length; r += 1) {
                    int digits = f * r;
                    boolean lostDigits = (r & 1) != 0;
                   
                    contexts[i++] = new MathContext(digits, forms[f], lostDigits, rounds[r]);
                }
            }
           
            return contexts;
        }
View Full Code Here

            return contexts;
        }
       
        public boolean hasSameBehavior(Object a, Object b)
        {
            MathContext mca = (MathContext) a;
            MathContext mcb = (MathContext) b;
           
            return mca.toString().equals(mcb.toString());
        }
View Full Code Here

     * @param newValue desired MathContext
     * @see #getMathContext
     * @stable ICU 4.2
     */
    public void setMathContext(java.math.MathContext newValue) {
        mathContext = new MathContext(newValue.getPrecision(), MathContext.SCIENTIFIC, false,
                                      (newValue.getRoundingMode()).ordinal());
    }
View Full Code Here

   *            desired MathContext
   * @see #getMathContext
   * @stable ICU 4.2
   */
  public void setMathContext(final java.math.MathContext newValue) {
    mathContext = new MathContext(newValue.getPrecision(), MathContext.SCIENTIFIC, false, (newValue.getRoundingMode()).ordinal());
  }
View Full Code Here

TOP

Related Classes of com.ibm.icu.math.MathContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.