use of ch.obermuhlner.math.big.BigFloat.Context in project big-math by eobermuhlner.
the class BigFloatTest method testIsZero.
@Test
public void testIsZero() {
Context context = context(MathContext.DECIMAL32);
assertEquals(false, context.valueOf("-1E999").isZero());
assertEquals(false, context.valueOf("-1E-999").isZero());
assertEquals(false, context.valueOf(-5).isZero());
assertEquals(true, context.valueOf(0).isZero());
assertEquals(true, context.valueOf("0.000000").isZero());
assertEquals(false, context.valueOf(5).isZero());
assertEquals(false, context.valueOf("1E999").isZero());
assertEquals(false, context.valueOf("1E-999").isZero());
}
use of ch.obermuhlner.math.big.BigFloat.Context in project big-math by eobermuhlner.
the class BigFloatTest method testIsGreaterThan.
@Test
public void testIsGreaterThan() {
Context context = context(MathContext.DECIMAL32);
assertEquals(true, context.valueOf(5).isGreaterThan(context.valueOf(1)));
assertEquals(false, context.valueOf(1).isGreaterThan(context.valueOf(5)));
assertEquals(false, context.valueOf(5).isGreaterThan(context.valueOf(5)));
}
use of ch.obermuhlner.math.big.BigFloat.Context in project big-math by eobermuhlner.
the class BigFloatTest method testPi.
@Test
public void testPi() {
Context context = context(MathContext.DECIMAL32);
assertEquals(BigDecimalMath.pi(context.getMathContext()), context.pi().toBigDecimal());
}
use of ch.obermuhlner.math.big.BigFloat.Context in project big-math by eobermuhlner.
the class BigFloatTest method testEquals.
@Test
public void testEquals() {
Context context = context(MathContext.DECIMAL32);
assertNotEquals(context.valueOf(1234), null);
assertNotEquals(context.valueOf(1234), "string");
BigFloat value1 = context.valueOf(1);
assertEquals(value1, value1);
assertEquals(context.valueOf(1234), context.valueOf(1234));
assertNotEquals(context.valueOf(1234), context.valueOf(9999));
assertNotEquals(context.valueOf(9999), context.valueOf(1234));
Context equalContext = context(MathContext.DECIMAL32);
assertEquals(context, equalContext);
assertEquals(context.valueOf(1234), equalContext.valueOf(1234));
assertEquals(context.valueOf(1234), equalContext.valueOf(1234.0));
assertEquals(context.valueOf(1234), equalContext.valueOf("1234.0000"));
assertEquals(equalContext.valueOf(1234), context.valueOf(1234));
Context anotherContext = context(MathContext.DECIMAL64);
assertNotEquals(context, anotherContext);
assertEquals(context.valueOf(1234), anotherContext.valueOf(1234));
assertEquals(anotherContext.valueOf(1234), context.valueOf(1234));
}
use of ch.obermuhlner.math.big.BigFloat.Context in project big-math by eobermuhlner.
the class BigFloatTest method testSignum.
@Test
public void testSignum() {
Context context = context(MathContext.DECIMAL32);
assertEquals(-1, context.valueOf("-1E999").signum());
assertEquals(-1, context.valueOf("-1E-999").signum());
assertEquals(-1, context.valueOf(-5).signum());
assertEquals(0, context.valueOf(0).signum());
assertEquals(0, context.valueOf("0.000000").signum());
assertEquals(1, context.valueOf(5).signum());
assertEquals(1, context.valueOf("1E999").signum());
assertEquals(1, context.valueOf("1E-999").signum());
}
Aggregations