Search in sources :

Example 6 with Context

use of ch.obermuhlner.math.big.BigFloat.Context in project big-math by eobermuhlner.

the class BigFloatTest method testIsLessThanOrEqual.

@Test
public void testIsLessThanOrEqual() {
    Context context = context(MathContext.DECIMAL32);
    assertEquals(true, context.valueOf(1).isLessThanOrEqual(context.valueOf(5)));
    assertEquals(false, context.valueOf(5).isLessThanOrEqual(context.valueOf(1)));
    assertEquals(true, context.valueOf(5).isLessThanOrEqual(context.valueOf(5)));
}
Also used : MathContext(java.math.MathContext) Context(ch.obermuhlner.math.big.BigFloat.Context) Test(org.junit.Test)

Example 7 with Context

use of ch.obermuhlner.math.big.BigFloat.Context in project big-math by eobermuhlner.

the class BigFloatTest method testCompareTo.

@Test
public void testCompareTo() {
    Context context = context(MathContext.DECIMAL32);
    assertEquals(1, context.valueOf(5).compareTo(context.valueOf(1)));
    assertEquals(-1, context.valueOf(1).compareTo(context.valueOf(5)));
    assertEquals(0, context.valueOf(5).compareTo(context.valueOf(5)));
}
Also used : MathContext(java.math.MathContext) Context(ch.obermuhlner.math.big.BigFloat.Context) Test(org.junit.Test)

Example 8 with Context

use of ch.obermuhlner.math.big.BigFloat.Context in project big-math by eobermuhlner.

the class BigFloatTest method testPow.

@Test
public void testPow() {
    Context context = context(MathContext.DECIMAL32);
    assertEquals(context.valueOf(8), context.valueOf(2).pow(3));
    assertEquals(context.valueOf(8), context.valueOf(2).pow(3L));
    assertEquals(context.valueOf(8), context.valueOf(2).pow(3.0));
    assertEquals(context.valueOf(8), context.valueOf(2).pow(BigDecimal.valueOf(3)));
    assertEquals(context.valueOf(8), context.valueOf(2).pow(context.valueOf(3)));
}
Also used : MathContext(java.math.MathContext) Context(ch.obermuhlner.math.big.BigFloat.Context) Test(org.junit.Test)

Example 9 with Context

use of ch.obermuhlner.math.big.BigFloat.Context in project big-math by eobermuhlner.

the class BigFloatTest method testRoot2.

@Test
public void testRoot2() {
    Context context = context(MathContext.DECIMAL32);
    assertEquals(context.valueOf(8).root(3).toBigDecimal(), BigDecimalMath.root(BigDecimal.valueOf(8), BigDecimal.valueOf(3), MathContext.DECIMAL32));
}
Also used : MathContext(java.math.MathContext) Context(ch.obermuhlner.math.big.BigFloat.Context) Test(org.junit.Test)

Example 10 with Context

use of ch.obermuhlner.math.big.BigFloat.Context in project big-math by eobermuhlner.

the class BigFloatTest method testLog2.

@Test
public void testLog2() {
    Context context = context(MathContext.DECIMAL32);
    assertEquals(log2(context.valueOf(3)).toBigDecimal(), BigDecimalMath.log2(BigDecimal.valueOf(3), MathContext.DECIMAL32));
}
Also used : MathContext(java.math.MathContext) Context(ch.obermuhlner.math.big.BigFloat.Context) Test(org.junit.Test)

Aggregations

Context (ch.obermuhlner.math.big.BigFloat.Context)78 Test (org.junit.Test)76 MathContext (java.math.MathContext)61 BigFloat (ch.obermuhlner.math.big.BigFloat)15