Search in sources :

Example 56 with Context

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

the class BigFloatTest method testLog.

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

Example 57 with Context

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

the class BigFloatTest method testToInt.

@Test
public void testToInt() {
    Context context = context(MathContext.DECIMAL64);
    assertEquals(1234, context.valueOf(1234).toInt());
}
Also used : MathContext(java.math.MathContext) Context(ch.obermuhlner.math.big.BigFloat.Context) Test(org.junit.Test)

Example 58 with Context

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

the class BigFloatTest method testFactorial.

@Test
public void testFactorial() {
    Context context = context(MathContext.DECIMAL32);
    assertEquals(context.valueOf(720), context.factorial(6));
}
Also used : MathContext(java.math.MathContext) Context(ch.obermuhlner.math.big.BigFloat.Context) Test(org.junit.Test)

Example 59 with Context

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

the class BigFloatTest method testMax.

@Test
public void testMax() {
    Context context = context(MathContext.DECIMAL32);
    assertEquals(context.valueOf(9), max(context.valueOf(9), context.valueOf(2)));
    assertEquals(context.valueOf(9), max(context.valueOf(2), context.valueOf(9)));
    assertEquals(context.valueOf(9), max(context.valueOf(2), context.valueOf(9), context.valueOf(3)));
    assertEquals(context.valueOf(9), max(context.valueOf(9), context.valueOf(2), context.valueOf(3)));
}
Also used : MathContext(java.math.MathContext) Context(ch.obermuhlner.math.big.BigFloat.Context) Test(org.junit.Test)

Example 60 with Context

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

the class BigFloatTest method testPow2.

@Test
public void testPow2() {
    Context context = context(MathContext.DECIMAL32);
    assertEquals(context.valueOf(2).pow(3).toBigDecimal(), BigDecimalMath.pow(BigDecimal.valueOf(2), 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