Search in sources :

Example 56 with RoundingMode

use of java.math.RoundingMode in project guava by hceylan.

the class LongMathTest method testLog10ZeroAlwaysThrows.

public void testLog10ZeroAlwaysThrows() {
    for (RoundingMode mode : ALL_ROUNDING_MODES) {
        try {
            LongMath.log10(0L, mode);
            fail("Expected IllegalArgumentException");
        } catch (IllegalArgumentException expected) {
        }
    }
}
Also used : RoundingMode(java.math.RoundingMode)

Example 57 with RoundingMode

use of java.math.RoundingMode in project guava by hceylan.

the class LongMathTest method testLog2NegativeAlwaysThrows.

public void testLog2NegativeAlwaysThrows() {
    for (long x : NEGATIVE_LONG_CANDIDATES) {
        for (RoundingMode mode : ALL_ROUNDING_MODES) {
            try {
                LongMath.log2(x, mode);
                fail("Expected IllegalArgumentException");
            } catch (IllegalArgumentException expected) {
            }
        }
    }
}
Also used : RoundingMode(java.math.RoundingMode)

Example 58 with RoundingMode

use of java.math.RoundingMode in project guava by hceylan.

the class BigIntegerMathTest method testLog2Floor.

public void testLog2Floor() {
    for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
        for (RoundingMode mode : asList(FLOOR, DOWN)) {
            int result = BigIntegerMath.log2(x, mode);
            assertTrue(ZERO.setBit(result).compareTo(x) <= 0);
            assertTrue(ZERO.setBit(result + 1).compareTo(x) > 0);
        }
    }
}
Also used : RoundingMode(java.math.RoundingMode) BigInteger(java.math.BigInteger)

Example 59 with RoundingMode

use of java.math.RoundingMode in project guava by hceylan.

the class BigIntegerMathTest method testSqrtNegativeAlwaysThrows.

public void testSqrtNegativeAlwaysThrows() {
    for (BigInteger x : NEGATIVE_BIGINTEGER_CANDIDATES) {
        for (RoundingMode mode : ALL_ROUNDING_MODES) {
            try {
                BigIntegerMath.sqrt(x, mode);
                fail("Expected IllegalArgumentException");
            } catch (IllegalArgumentException expected) {
            }
        }
    }
}
Also used : RoundingMode(java.math.RoundingMode) BigInteger(java.math.BigInteger)

Example 60 with RoundingMode

use of java.math.RoundingMode in project guava by hceylan.

the class BigIntegerMathTest method testLog10NegativeAlwaysThrows.

public void testLog10NegativeAlwaysThrows() {
    for (BigInteger x : POSITIVE_BIGINTEGER_CANDIDATES) {
        for (RoundingMode mode : ALL_ROUNDING_MODES) {
            try {
                BigIntegerMath.log10(x.negate(), mode);
                fail("Expected IllegalArgumentException");
            } catch (IllegalArgumentException expected) {
            }
        }
    }
}
Also used : RoundingMode(java.math.RoundingMode) BigInteger(java.math.BigInteger)

Aggregations

RoundingMode (java.math.RoundingMode)206 BigDecimal (java.math.BigDecimal)127 BigInteger (java.math.BigInteger)88 MathContext (java.math.MathContext)72 GwtIncompatible (com.google.common.annotations.GwtIncompatible)39 DecimalFormat (java.text.DecimalFormat)5 IDataMap (permafrost.tundra.data.IDataMap)5 Test (org.junit.Test)3 MifosConfigurationManager (org.mifos.config.business.MifosConfigurationManager)3 GridBagConstraints (java.awt.GridBagConstraints)2 GridBagLayout (java.awt.GridBagLayout)2 Insets (java.awt.Insets)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 ButtonGroup (javax.swing.ButtonGroup)2 JLabel (javax.swing.JLabel)2 JPanel (javax.swing.JPanel)2 JRadioButton (javax.swing.JRadioButton)2 JSpinner (javax.swing.JSpinner)2 SpinnerNumberModel (javax.swing.SpinnerNumberModel)2