Search in sources :

Example 1 with BigFloat

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

the class BigFloatStreamTest method testRangeClosedStep3.

@Test
public void testRangeClosedStep3() {
    Context context = BigFloat.context(20);
    List<BigFloat> list = BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(12), context.valueOf(3)).collect(Collectors.toList());
    assertEquals(5, list.size());
    assertEquals(true, list.contains(context.valueOf(0)));
    assertEquals(true, list.contains(context.valueOf(3)));
    assertEquals(true, list.contains(context.valueOf(6)));
    assertEquals(true, list.contains(context.valueOf(9)));
    assertEquals(true, list.contains(context.valueOf(12)));
    assertEquals(0, BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(-1), context.valueOf(3)).collect(Collectors.toList()).size());
    assertEquals(1, BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(0), context.valueOf(3)).collect(Collectors.toList()).size());
    assertEquals(1, BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(1), context.valueOf(3)).collect(Collectors.toList()).size());
    assertEquals(1, BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(2), context.valueOf(3)).collect(Collectors.toList()).size());
    assertEquals(2, BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(3), context.valueOf(3)).collect(Collectors.toList()).size());
    assertEquals(2, BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(4), context.valueOf(3)).collect(Collectors.toList()).size());
    assertEquals(2, BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(5), context.valueOf(3)).collect(Collectors.toList()).size());
    assertEquals(3, BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(6), context.valueOf(3)).collect(Collectors.toList()).size());
    assertEquals(3, BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(7), context.valueOf(3)).collect(Collectors.toList()).size());
    assertEquals(3, BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(8), context.valueOf(3)).collect(Collectors.toList()).size());
    assertEquals(4, BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(9), context.valueOf(3)).collect(Collectors.toList()).size());
    assertEquals(4, BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(10), context.valueOf(3)).collect(Collectors.toList()).size());
    assertEquals(4, BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(11), context.valueOf(3)).collect(Collectors.toList()).size());
    assertEquals(5, BigFloatStream.rangeClosed(context.valueOf(0), context.valueOf(12), context.valueOf(3)).collect(Collectors.toList()).size());
}
Also used : Context(ch.obermuhlner.math.big.BigFloat.Context) BigFloat(ch.obermuhlner.math.big.BigFloat) Test(org.junit.Test)

Example 2 with BigFloat

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

the class BigFloatStreamTest method testRangeLongStep3.

@Test
public void testRangeLongStep3() {
    Context context = BigFloat.context(20);
    List<BigFloat> list = BigFloatStream.range(0, 10, 3, context).collect(Collectors.toList());
    assertEquals(4, list.size());
    assertEquals(true, list.contains(context.valueOf(0)));
    assertEquals(true, list.contains(context.valueOf(3)));
    assertEquals(true, list.contains(context.valueOf(6)));
    assertEquals(true, list.contains(context.valueOf(9)));
}
Also used : Context(ch.obermuhlner.math.big.BigFloat.Context) BigFloat(ch.obermuhlner.math.big.BigFloat) Test(org.junit.Test)

Example 3 with BigFloat

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

the class BigFloatStreamTest method testRangeClosedDown.

@Test
public void testRangeClosedDown() {
    Context context = BigFloat.context(20);
    List<BigFloat> list = BigFloatStream.rangeClosed(context.valueOf(10), context.valueOf(0), context.valueOf(-1)).collect(Collectors.toList());
    assertListClosed(list, 0, 10);
}
Also used : Context(ch.obermuhlner.math.big.BigFloat.Context) BigFloat(ch.obermuhlner.math.big.BigFloat) Test(org.junit.Test)

Example 4 with BigFloat

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

the class BigFloatStreamTest method testRangeDown.

@Test
public void testRangeDown() {
    Context context = BigFloat.context(20);
    List<BigFloat> list = BigFloatStream.range(context.valueOf(9), context.valueOf(-1), 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)

Example 5 with BigFloat

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

the class BigFloatStreamTest method testRangeDoubleStep3.

@Test
public void testRangeDoubleStep3() {
    Context context = BigFloat.context(20);
    List<BigFloat> list = BigFloatStream.range(0.0, 10.0, 3.0, context).collect(Collectors.toList());
    assertEquals(4, list.size());
    assertEquals(true, list.contains(context.valueOf(0)));
    assertEquals(true, list.contains(context.valueOf(3)));
    assertEquals(true, list.contains(context.valueOf(6)));
    assertEquals(true, list.contains(context.valueOf(9)));
}
Also used : Context(ch.obermuhlner.math.big.BigFloat.Context) BigFloat(ch.obermuhlner.math.big.BigFloat) Test(org.junit.Test)

Aggregations

BigFloat (ch.obermuhlner.math.big.BigFloat)15 Context (ch.obermuhlner.math.big.BigFloat.Context)15 Test (org.junit.Test)14 MathContext (java.math.MathContext)1