Search in sources :

Example 46 with Context

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

the class BigFloatTest method testNegate.

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

Example 47 with Context

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

the class BigFloatTest method testSin.

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

Example 48 with Context

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

the class BigFloatTest method testAcos.

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

Example 49 with Context

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

the class BigFloatTest method testToLong.

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

Example 50 with Context

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

the class BigFloatTest method testIsPositive.

@Test
public void testIsPositive() {
    Context context = context(MathContext.DECIMAL32);
    assertEquals(false, context.valueOf("-1E999").isPositive());
    assertEquals(false, context.valueOf("-1E-999").isPositive());
    assertEquals(false, context.valueOf(-5).isPositive());
    assertEquals(false, context.valueOf(0).isPositive());
    assertEquals(false, context.valueOf("0.000000").isPositive());
    assertEquals(true, context.valueOf(5).isPositive());
    assertEquals(true, context.valueOf("1E999").isPositive());
    assertEquals(true, context.valueOf("1E-999").isPositive());
}
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