test/java/math/BigDecimal/IntegralDivisionTests.java

Print this page




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  */
  23 /*
  24  * @test
  25  * @bug 4904082 4917089 6337226
  26  * @summary Tests that integral division and related methods return the proper result and scale.
  27  * @author Joseph D. Darcy
  28  * @compile -source 1.5 IntegralDivisionTests.java
  29  * @run main IntegralDivisionTests
  30  */
  31 import java.math.*;
  32 public class IntegralDivisionTests {
  33 
  34     static int dividetoIntegralValueTests() {
  35         int failures = 0;
  36 
  37         // Exact integer quotient should have the same results from
  38         // the exact divide and dividetoIntegralValue
  39 
  40 
  41         // Rounded results
  42         BigDecimal [][] moreTestCases = {
  43             {new BigDecimal("11003"),   new BigDecimal("10"),   new BigDecimal("1100")},
  44             {new BigDecimal("11003"),   new BigDecimal("1e1"),  new BigDecimal("1100.0")},
  45             {new BigDecimal("1e9"),     new BigDecimal("1"),    new BigDecimal("1e9")},
  46             {new BigDecimal("1e9"),     new BigDecimal("1.00"), new BigDecimal("1e9")},
  47             {new BigDecimal("1e9"),     new BigDecimal("0.1"),  new BigDecimal("1e10")},
  48             {new BigDecimal("10e8"),    new BigDecimal("0.1"),  new BigDecimal("10e9")},
  49             {new BigDecimal("400e1"),   new BigDecimal("5"),    new BigDecimal("80e1")},




   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
  20  * CA 95054 USA or visit www.sun.com if you need additional information or
  21  * have any questions.
  22  */
  23 /*
  24  * @test
  25  * @bug 4904082 4917089 6337226
  26  * @summary Tests that integral division and related methods return the proper result and scale.
  27  * @author Joseph D. Darcy


  28  */
  29 import java.math.*;
  30 public class IntegralDivisionTests {
  31 
  32     static int dividetoIntegralValueTests() {
  33         int failures = 0;
  34 
  35         // Exact integer quotient should have the same results from
  36         // the exact divide and dividetoIntegralValue
  37 
  38 
  39         // Rounded results
  40         BigDecimal [][] moreTestCases = {
  41             {new BigDecimal("11003"),   new BigDecimal("10"),   new BigDecimal("1100")},
  42             {new BigDecimal("11003"),   new BigDecimal("1e1"),  new BigDecimal("1100.0")},
  43             {new BigDecimal("1e9"),     new BigDecimal("1"),    new BigDecimal("1e9")},
  44             {new BigDecimal("1e9"),     new BigDecimal("1.00"), new BigDecimal("1e9")},
  45             {new BigDecimal("1e9"),     new BigDecimal("0.1"),  new BigDecimal("1e10")},
  46             {new BigDecimal("10e8"),    new BigDecimal("0.1"),  new BigDecimal("10e9")},
  47             {new BigDecimal("400e1"),   new BigDecimal("5"),    new BigDecimal("80e1")},