1 USING: kernel math.constants math.continued-fractions tools.test ;
3 { V{ 2 2.0 } } [ V{ 2.5 } dup next-approx ] unit-test
4 { V{ 2 2 } } [ V{ 2.5 } dup next-approx dup next-approx ] unit-test
6 { 5/2 } [ V{ 2 2.1 } >ratio ] unit-test
7 { 5/2 } [ V{ 2 1.9 } >ratio ] unit-test
8 { 5/2 } [ V{ 2 2.0 } >ratio ] unit-test
9 { 5/2 } [ V{ 2 2 } >ratio ] unit-test
11 { 3 } [ 1 pi approx ] unit-test
12 { 22/7 } [ 0.1 pi approx ] unit-test
13 { 355/113 } [ 0.00001 pi approx ] unit-test
15 { 2 } [ 1 2 approx ] unit-test
16 { 2 } [ 0.1 2 approx ] unit-test
17 { 2 } [ 0.00001 2 approx ] unit-test
19 { 3 } [ 1 2.5 approx ] unit-test
20 { 5/2 } [ 0.1 2.5 approx ] unit-test
21 { 5/2 } [ 0.0001 2.5 approx ] unit-test