File tree Expand file tree Collapse file tree 1 file changed +18
-4
lines changed
sources/net.sf.j2s.java.core/src/test Expand file tree Collapse file tree 1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -17,10 +17,11 @@ public static void main(String[] args) {
1717 testBDMul ();
1818 testBDDiv ();
1919
20+ System .out .println ("testBD OK" );
2021
2122 }
2223
23- // failing testBDMul ();
24+ // failing testBDDiv ();
2425
2526
2627
@@ -67,10 +68,23 @@ private static void testBDMul() {
6768 }
6869
6970 private static void testBDDiv () {
70- BigDecimal g ;
71- g = BigDecimal .valueOf (5 ).divide (BigDecimal .valueOf (2 ));
71+ BigDecimal g , a , b ;
72+ a = new BigDecimal (0 );
73+ b = new BigDecimal (2.01 );
74+ g = a .divide (b ,10 ,BigDecimal .ROUND_DOWN );
75+ System .out .println (g );
76+ a = new BigDecimal (5.1 );
77+ b = new BigDecimal (2.01 );
78+ g = a .divide (b ,10 ,BigDecimal .ROUND_DOWN );
7279 System .out .println (g );
73- assert (g .toString ().equals ("2.5" ));
80+ assert (g .toString ().equals ("2.5373134328" ));
81+ String zeros = "" ;
82+ for (int i = 0 ; i < 10 ; i ++) {
83+ g = new BigDecimal ("50" + zeros ).divide (BigDecimal .valueOf (2 ), 10 , BigDecimal .ROUND_DOWN );
84+ System .out .println (g );
85+ assert (g .toString ().equals ("25" + zeros + ".0000000000" ));
86+ zeros += "0" ;
87+ }
7488 System .out .println ("testBDDiv OK" );
7589 }
7690
You can’t perform that action at this time.
0 commit comments