Search in sources :

Example 71 with Context

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

the class BigFloatTest method testToDouble.

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

Example 72 with Context

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

the class BigFloatTest method testSubtract.

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

Example 73 with Context

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

the class BigFloatTest method testAcoth.

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

Example 74 with Context

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

the class BigFloatTest method testCosh.

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

Example 75 with Context

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

the class BigFloatStreamTest method testRangeStep1.

@Test
public void testRangeStep1() {
    Context context = BigFloat.context(20);
    List<BigFloat> list = BigFloatStream.range(context.valueOf(0), context.valueOf(10), context.valueOf(1)).collect(Collectors.toList());
    assertList(list, 0, 10);
}
Also used : Context(ch.obermuhlner.math.big.BigFloat.Context) BigFloat(ch.obermuhlner.math.big.BigFloat) 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