Search in sources :

Example 1 with Context

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

the class BigFloatTest method testAdd.

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

Example 2 with Context

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

the class BigFloatTest method testGetIntegralPart.

@Test
public void testGetIntegralPart() {
    Context context = context(MathContext.DECIMAL32);
    assertEquals(context.valueOf(123), context.valueOf(123.456).getIntegralPart());
}
Also used : MathContext(java.math.MathContext) Context(ch.obermuhlner.math.big.BigFloat.Context) Test(org.junit.Test)

Example 3 with Context

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

the class BigFloatTest method testSinh.

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

Example 4 with Context

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

the class BigFloatTest method testExp.

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

Example 5 with Context

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

the class BigFloatTest method testSqrt.

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