You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@harmony.apache.org by Tim Ellison <t....@gmail.com> on 2006/03/29 11:15:46 UTC

Re: svn commit: r389715 [1/12] - in /incubator/harmony/enhanced/classlib/trunk: make/ modules/math/META-INF/ modules/math/make/ modules/math/make/common/ modules/math/src/main/java/java/math/ modules/math/src/test/java/org/ modules/math/src/test/java/org/a...

FYI: this 'big commit' is simply a restructuring of existing math code
into its own module.  It is not new code.

Regards,
Tim

tellison@apache.org wrote:
> Author: tellison
> Date: Wed Mar 29 01:01:04 2006
> New Revision: 389715
> 
> URL: http://svn.apache.org/viewcvs?rev=389715&view=rev
> Log:
> Apply patch HARMONY-243 (new math implementation needs to be integrated)
> 
> Added:
>     incubator/harmony/enhanced/classlib/trunk/modules/math/make/
>     incubator/harmony/enhanced/classlib/trunk/modules/math/make/build.xml
>     incubator/harmony/enhanced/classlib/trunk/modules/math/make/common/
>     incubator/harmony/enhanced/classlib/trunk/modules/math/make/common/build.xml
>     incubator/harmony/enhanced/classlib/trunk/modules/math/make/common/hyproperties.xml
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigDecimal.java
>       - copied unchanged from r389571, incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/math/BigDecimal.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/main/java/java/math/BigInteger.java
>       - copied unchanged from r389571, incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/math/BigInteger.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/
>       - copied from r389571, incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/math/
> Removed:
>     incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/math/BigDecimal.java
>     incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/src/common/javasrc/java/math/BigInteger.java
>     incubator/harmony/enhanced/classlib/trunk/modules/regex-beans-math/test/common/unit/java/math/
> Modified:
>     incubator/harmony/enhanced/classlib/trunk/make/build-test.xml
>     incubator/harmony/enhanced/classlib/trunk/modules/math/META-INF/MANIFEST.MF
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigDecimalArithmeticTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigDecimalCompareTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigDecimalConstructorsTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigDecimalConvertTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigDecimalScaleOperationsTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigIntegerAddTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigIntegerAndTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigIntegerCompareTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigIntegerConstructorsTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigIntegerConvertTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigIntegerDivideTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigIntegerHashCodeTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigIntegerModPowTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigIntegerMultiplyTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigIntegerNotTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigIntegerOperateBitsTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigIntegerOrTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigIntegerSubtractTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigIntegerToStringTest.java
>     incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigIntegerXorTest.java
> 
> Modified: incubator/harmony/enhanced/classlib/trunk/make/build-test.xml
> URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/make/build-test.xml?rev=389715&r1=389714&r2=389715&view=diff
> ==============================================================================
> --- incubator/harmony/enhanced/classlib/trunk/make/build-test.xml (original)
> +++ incubator/harmony/enhanced/classlib/trunk/make/build-test.xml Wed Mar 29 01:01:04 2006
> @@ -43,7 +43,7 @@
>  
>  	<!-- this list of components to test will grow to eventually be all modules -->
>  	<target name="test-all"
> -		depends="clean, test-luni, test-archive, test-text, test-nio, test-xnet, test-nio_char, test-jndi, test-sql, test-prefs, test-beans, gen-report">
> +		depends="clean, test-luni, test-archive, test-text, test-nio, test-xnet, test-nio_char, test-jndi, test-sql, test-prefs, test-beans, test-math, gen-report">
>  	</target>
>  
>  	<target name="clean">
> @@ -138,7 +138,14 @@
>              <echo message="=================================="/>
>              <ant antfile="make/build.xml" dir="modules/beans" target="test" />
>  	</target>
> -		
> +
> +	<target name="test-math">
> +            <echo message="=================================="/>
> +            <echo message="Running tests for module math"/>
> +            <echo message="=================================="/>
> +            <ant antfile="make/build.xml" dir="modules/math" target="test" />
> +	</target>
> +
>  	<target name="test-security">
>  	
>          <echo message="=================================="/>
> 
> Modified: incubator/harmony/enhanced/classlib/trunk/modules/math/META-INF/MANIFEST.MF
> URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/math/META-INF/MANIFEST.MF?rev=389715&r1=389714&r2=389715&view=diff
> ==============================================================================
> --- incubator/harmony/enhanced/classlib/trunk/modules/math/META-INF/MANIFEST.MF (original)
> +++ incubator/harmony/enhanced/classlib/trunk/modules/math/META-INF/MANIFEST.MF Wed Mar 29 01:01:04 2006
> @@ -7,4 +7,6 @@
>  Eclipse-JREBundle: true
>  Export-Package: java.math
>  Import-Package: java.util,
> - java.lang
> + java.lang,
> + java.io
> +
> 
> Added: incubator/harmony/enhanced/classlib/trunk/modules/math/make/build.xml
> URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/math/make/build.xml?rev=389715&view=auto
> ==============================================================================
> --- incubator/harmony/enhanced/classlib/trunk/modules/math/make/build.xml (added)
> +++ incubator/harmony/enhanced/classlib/trunk/modules/math/make/build.xml Wed Mar 29 01:01:04 2006
> @@ -0,0 +1,114 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<!--
> +    Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
> +  
> +    Licensed under the Apache License, Version 2.0 (the "License");
> +    you may not use this file except in compliance with the License.
> +    You may obtain a copy of the License at
> +  
> +       http://www.apache.org/licenses/LICENSE-2.0
> +  
> +    Unless required by applicable law or agreed to in writing, software
> +    distributed under the License is distributed on an "AS IS" BASIS,
> +    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> +    See the License for the specific language governing permissions and
> +    limitations under the License.
> +-->
> +
> +<project name="MATH Build" default="build" basedir="..">
> +	<description>Build for MATH component</description>
> +
> +	<!-- set global properties for this build. -->
> +	<xmlproperty file="make/common/hyproperties.xml" semanticAttributes="true"/>
> +	<property environment="env"/>
> +
> +	<!-- Determine the (normalized) operating system family -->
> +	<condition property="if.win">
> +		<os family="Windows" />
> +	</condition>
> +	<condition property="hy.os_family" value="windows">
> +		<isset property="if.win"/>
> +	</condition>
> +
> +	<condition property="if.linux">
> +		<and>
> +			<os name="linux" />
> +			<os family="unix" />
> +		</and>
> +	</condition>
> +	<condition property="hy.os_family" value="linux">
> +		<isset property="if.linux"/>
> +	</condition>
> +
> +
> +	<!-- Determine the (normalized) processor family -->
> +	<condition property="if.x86_64">
> +		<contains string="${os.arch}" substring="x86_64"/>
> +	</condition>
> +	<condition property="hy.cpu_family" value="x86_64">
> +		<isset property="if.x86_64"/>
> +	</condition>
> +	
> +	<condition property="if.x86">
> +		<and>
> +			<contains string="${os.arch}" substring="86"/>
> +			<not>
> +				<isset property="if.x86_64"/>
> +			</not>
> +		</and>
> +	</condition>
> +	<condition property="hy.cpu_family" value="x86">
> +		<isset property="if.x86"/>
> +	</condition>
> +	
> +	<condition property="if.ipf">
> +		<contains string="${os.arch}" substring="ia64"/>
> +	</condition>
> +	<condition property="hy.cpu_family" value="ipf">
> +		<isset property="if.ipf"/>
> +	</condition>
> +
> +	<!-- Define the platform property dependant upon the OS and platform -->
> +	<property name="hy.platform" value="${hy.os_family}.${hy.cpu_family}"/>
> +
> +	<!-- Set the java compiler to be the Eclipse Java compiler -->
> +	<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter" />
> +
> +
> +	<target name="init">
> +		<tstamp>
> +			<format property="build-date" pattern="yyyyMMdd" locale="en" />
> +		</tstamp>
> +		<tstamp>
> +			<format property="build-time" pattern="yyyyMMdd_HHmm" />
> +		</tstamp>
> +		<echo message="build-date=${build-date}" />
> +		<echo message="build-time=${build-time}" />
> +		<echo message="on platform=${os.name} version=${os.version} arch=${os.arch}" />
> +
> +		<property name="java.debug.option" value="on" />
> +		<property name="native.debug.option" value="on" />
> +
> +		<property name="source.ver" value="1.4" />
> +	</target>
> +	
> +	<!-- MATH TARGETS -->
> +
> +	<target name="build" depends="init">
> +		<ant dir="make/common" target="compile.java" />
> +		<ant dir="make/common" target="build.jar" />
> +		<ant dir="make/common" target="copy.resources" />
> +	</target>
> +
> +
> +	<target name="test" depends="build">
> +		<ant dir="make/common" target="compile.tests" />
> +		<ant dir="make/common" target="run.tests" />
> +	</target>
> +
> +	<target name="clean">
> +		<delete dir="${hy.math.bin.main}"/>
> +		<delete dir="${hy.math.bin.test}"/>
> +	</target>
> +
> +</project>
> 
> Added: incubator/harmony/enhanced/classlib/trunk/modules/math/make/common/build.xml
> URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/math/make/common/build.xml?rev=389715&view=auto
> ==============================================================================
> --- incubator/harmony/enhanced/classlib/trunk/modules/math/make/common/build.xml (added)
> +++ incubator/harmony/enhanced/classlib/trunk/modules/math/make/common/build.xml Wed Mar 29 01:01:04 2006
> @@ -0,0 +1,108 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<!--
> +    Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
> +  
> +    Licensed under the Apache License, Version 2.0 (the "License");
> +    you may not use this file except in compliance with the License.
> +    You may obtain a copy of the License at
> +  
> +       http://www.apache.org/licenses/LICENSE-2.0
> +  
> +    Unless required by applicable law or agreed to in writing, software
> +    distributed under the License is distributed on an "AS IS" BASIS,
> +    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> +    See the License for the specific language governing permissions and
> +    limitations under the License.
> +-->
> +
> +<project name="Common_MATH_Build">
> +	
> +	<target name="compile.java" description="Compile MATH java code">
> +		<echo message="Compiling MATH classes from ${hy.math.src.main.java}" />
> +		
> +		<mkdir dir="${hy.math.bin.main}" />
> +
> +		<javac sourcepath=""
> +			srcdir="${hy.math.src.main.java}"
> +			destdir="${hy.math.bin.main}"
> +			source="${source.ver}"
> +			debug="${java.debug.option}">
> +
> +			<bootclasspath>
> +				<fileset dir="${hy.target}/jre/lib/boot">
> +					<include name="*.jar" />
> +				</fileset>
> +			</bootclasspath>
> +		</javac>
> +	</target>
> +	
> +	<target name="build.jar">
> +		<jar destfile="${hy.target}/jre/lib/boot/math.jar"
> +			manifest="${hy.math}/META-INF/MANIFEST.MF">
> +			<fileset dir="${hy.math.bin.main}" />
> +		</jar>
> +	</target>
> +
> +	
> +	<target name="compile.tests">
> +		<echo message="Compiling MATH tests from ${hy.math.src.test.java}" />
> +
> +		<mkdir dir="${hy.math.bin.test}" />
> +
> +		<javac srcdir="${hy.math.src.test.java}"
> +			destdir="${hy.math.bin.test}"
> +			sourcepath=""
> +			source="${source.ver}"
> +			debug="${java.debug.option}">
> +
> +			<bootclasspath>
> +				<fileset dir="${hy.target}/jre/lib/boot">
> +					<include name="*.jar" />
> +				</fileset>
> +			</bootclasspath>
> +                        <classpath location="../../../../build/tests" />
> +		</javac>
> +	</target>
> +
> +
> +	<target name="run.tests">
> +		
> +	        <mkdir dir="${hy.tests.reports}" />
> +
> +	        <junit fork="yes"
> +			forkmode="once"
> +			printsummary="withOutAndErr"
> +			errorproperty="test.error"
> +			showoutput="on"
> +			dir="${hy.math.bin.test}"
> +			jvm="${hy.target}/jre/bin/java">
> +
> +			<jvmarg value="-showversion"/>
> +
> +			<env key="JAVA_HOME" value="${hy.target}/jre"/>
> +
> +			<classpath>
> +				<pathelement path="${hy.math.bin.test}"/>
> +			</classpath>
> +                        <classpath location="../../../../build/tests" />
> +
> +			<formatter type="xml" />
> +
> +			<batchtest todir="${hy.tests.reports}" haltonfailure="no">
> +				<fileset dir="${hy.math.src.test.java}">
> +					<include name="**/*Test.java" />
> +    <!-- This test seems to loop -->
> +    <exclude name="**/api/java/math/BigDecimalTest.java" />
> +    <!-- This test fails -->
> +    <exclude name="**/api/java/math/BigIntegerTest.java" />
> +				</fileset>
> +			</batchtest>
> +		</junit>
> +	</target>
> +	
> +	
> +	<target name="copy.resources">
> +		<!-- Nothing for MATH -->
> +	</target>
> +</project>
> +
> 
> Added: incubator/harmony/enhanced/classlib/trunk/modules/math/make/common/hyproperties.xml
> URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/math/make/common/hyproperties.xml?rev=389715&view=auto
> ==============================================================================
> --- incubator/harmony/enhanced/classlib/trunk/modules/math/make/common/hyproperties.xml (added)
> +++ incubator/harmony/enhanced/classlib/trunk/modules/math/make/common/hyproperties.xml Wed Mar 29 01:01:04 2006
> @@ -0,0 +1,44 @@
> +<?xml version="1.0" encoding="UTF-8"?>
> +<!--
> +    Copyright 2006 The Apache Software Foundation or its licensors, as applicable.
> +  
> +    Licensed under the Apache License, Version 2.0 (the "License");
> +    you may not use this file except in compliance with the License.
> +    You may obtain a copy of the License at
> +  
> +       http://www.apache.org/licenses/LICENSE-2.0
> +  
> +    Unless required by applicable law or agreed to in writing, software
> +    distributed under the License is distributed on an "AS IS" BASIS,
> +    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> +    See the License for the specific language governing permissions and
> +    limitations under the License.
> +-->
> +
> +<hy>
> +   <math location=".">
> +      <src>
> +         <main>
> +            <java location="src/main/java" />
> +        	<resources location="src/main/resources" />
> +         </main>
> +         <test>
> +            <java location="src/test/java" />
> +            <resources location="src/main/resources" />
> +         </test>
> +         <natives location="src/natives" />
> +      </src>
> +      <bin>
> +        <main location="bin/main" />
> +        <test location="bin/test" />
> +      </bin>
> +      <packaging>
> +      </packaging>
> +   </math>
> +
> +   <target location="../../deploy" />
> +
> +   <tests>
> +      <reports location="../../build/test_report" />
> +   </tests>
> +</hy>
> 
> Modified: incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigDecimalArithmeticTest.java
> URL: http://svn.apache.org/viewcvs/incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigDecimalArithmeticTest.java?rev=389715&r1=389571&r2=389715&view=diff
> ==============================================================================
> --- incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigDecimalArithmeticTest.java (original)
> +++ incubator/harmony/enhanced/classlib/trunk/modules/math/src/test/java/org/apache/harmony/tests/math/BigDecimalArithmeticTest.java Wed Mar 29 01:01:04 2006
> @@ -1,762 +1,763 @@
> -/*
> - *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
> - *
> - *  Licensed under the Apache License, Version 2.0 (the "License");
> - *  you may not use this file except in compliance with the License.
> - *  You may obtain a copy of the License at
> - *
> - *     http://www.apache.org/licenses/LICENSE-2.0
> - *
> - *  Unless required by applicable law or agreed to in writing, software
> - *  distributed under the License is distributed on an "AS IS" BASIS,
> - *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> - *  See the License for the specific language governing permissions and
> - *  limitations under the License.
> - */
> -/**
> - * @author Elena Semukhina
> - * @version $Revision: 1.3.6.3 $
> - */
> -
> -package java.math;
> -
> -import junit.framework.TestCase;
> -import java.math.BigInteger;
> -
> -/**
> - * Class:  java.math.BigDecimal
> - * Methods: add, subtract, multiply, divide 
> - */
> -public class BigDecimalArithmeticTest extends TestCase {
> -    /**
> -     * Add two numbers of equal positive scales
> -     */
> -    public void testAddEqualScalePosPos() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = 10;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = 10;
> -        String c = "123121247898748373566323807282924555312937.1991359555";
> -        int cScale = 10;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.add(bNumber);
> -        assertTrue("incorrect value " + result.toString(), result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == cScale);
> -    }
> -
> -    /**
> -     * Add two numbers of equal negative scales
> -     */
> -    public void testAddEqualScaleNegNeg() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = -10;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = -10;
> -        String c = "1.231212478987483735663238072829245553129371991359555E+61";
> -        int cScale = -10;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.add(bNumber);
> -        assertTrue("incorrect value " + result.toString(), result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == cScale);
> -    }
> -
> -    /**
> -     * Add two numbers of different scales; the first is positive
> -     */
> -    public void testAddDiffScalePosNeg() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = 15;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = -10;
> -        String c = "7472334294161400358170962860775454459810457634.781384756794987";
> -        int cScale = 15;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.add(bNumber);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == cScale);
> -    }
> -
> -    /**
> -     * Add two numbers of different scales; the first is negative
> -     */
> -    public void testAddDiffScaleNegPos() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = -15;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = 10;
> -        String c = "1231212478987482988429808779810457634781459480137916301878791834798.7234564568";
> -        int cScale = 10;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.add(bNumber);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == cScale);
> -    }
> -
> -    /**
> -     * Add two zeroes of different scales; the first is negative
> -     */
> -    public void testAddDiffScaleZeroZero() {
> -        String a = "0";
> -        int aScale = -15;
> -        String b = "0";
> -        int bScale = 10;
> -        String c = "0E-10";
> -        int cScale = 10;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.add(bNumber);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == cScale);
> -    }
> -
> -    /**
> -     * Subtract two numbers of equal positive scales
> -     */
> -    public void testSubtractEqualScalePosPos() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = 10;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = 10;
> -        String c = "123121247898748224119637948679166971643339.7522230419";
> -        int cScale = 10;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.subtract(bNumber);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == cScale);
> -    }
> -
> -    /**
> -     * Subtract two numbers of equal negative scales
> -     */
> -    public void testSubtractEqualScaleNegNeg() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = -10;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = -10;
> -        String c = "1.231212478987482241196379486791669716433397522230419E+61";
> -        int cScale = -10;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.subtract(bNumber);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == cScale);
> -    }
> -
> -    /**
> -     * Subtract two numbers of different scales; the first is positive
> -     */
> -    public void testSubtractDiffScalePosNeg() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = 15;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = -10;
> -        String c = "-7472334291698975400195996883915836900189542365.218615243205013";
> -        int cScale = 15;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.subtract(bNumber);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == cScale);
> -    }
> -
> -    /**
> -     * Subtract two numbers of different scales; the first is negative
> -     */
> -    public void testSubtractDiffScaleNegPos() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = -15;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = 10;
> -        String c = "1231212478987482988429808779810457634781310033452057698121208165201.2765435432";
> -        int cScale = 10;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.subtract(bNumber);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == cScale);
> -    }
> -
> -    /**
> -     * Multiply two numbers of positive scales
> -     */
> -    public void testMultiplyScalePosPos() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = 15;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = 10;
> -        String c = "92000312286217574978643009574114545567010139156902666284589309.1880727173060570190220616";
> -        int cScale = 25;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.multiply(bNumber);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == cScale);
> -    }
> -
> -    /**
> -     * Multiply two numbers of negative scales
> -     */
> -    public void testMultiplyEqualScaleNegNeg() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = -15;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = -10;
> -        String c = "9.20003122862175749786430095741145455670101391569026662845893091880727173060570190220616E+111";
> -        int cScale = -25;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.multiply(bNumber);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == cScale);
> -    }
> -
> -    /**
> -     * Multiply two numbers of different scales
> -     */
> -    public void testMultiplyDiffScalePosNeg() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = 10;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = -10;
> -        String c = "920003122862175749786430095741145455670101391569026662845893091880727173060570190220616";
> -        int cScale = 0;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.multiply(bNumber);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == cScale);
> -    }
> -
> -    /**
> -     * Multiply two numbers of different scales
> -     */
> -    public void testMultiplyDiffScaleNegPos() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = -15;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = 10;
> -        String c = "9.20003122862175749786430095741145455670101391569026662845893091880727173060570190220616E+91";
> -        int cScale = -5;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.multiply(bNumber);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == cScale);
> -    }
> -
> -    /**
> -     * Divide by zero
> -     */
> -    public void testDivideByZero() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = 15;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = BigDecimal.valueOf(0L);
> -        try {
> -            BigDecimal result = aNumber.divide(bNumber, BigDecimal.ROUND_UNNECESSARY);
> -            fail("ArithmeticException has not been caught");
> -        } catch (ArithmeticException e) {
> -            assertTrue("Improper exception message", e.getMessage().equals("division by zero"));
> -        }
> -    }
> -
> -    /**
> -     * Divide with ROUND_UNNECESSARY
> -     */
> -    public void testDivideExceptionRM() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = 15;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = 10;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        try {
> -            BigDecimal result = aNumber.divide(bNumber, BigDecimal.ROUND_UNNECESSARY);
> -            fail("ArithmeticException has not been caught");
> -        } catch (ArithmeticException e) {
> -            assertTrue("Improper exception message", e.getMessage().equals("rounding mode is ROUND_UNNECESSARY but the result is not exact"));
> -        }
> -    }
> -
> -    /**
> -     * Divide with invalid rounding mode
> -     */
> -    public void testDivideExceptionInvalidRM() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = 15;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = 10;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        try {
> -            BigDecimal result = aNumber.divide(bNumber, 100);
> -            fail("IllegalArgumentException has not been caught");
> -        } catch (IllegalArgumentException e) {
> -            assertTrue("Improper exception message", e.getMessage().equals("invalid rounding mode"));
> -        }
> -    }
> -
> -    /**
> -     * Divide: local variable exponent is less than zero
> -     */
> -    public void testDivideExpLessZero() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = 15;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = 10;
> -        String c = "1.64770E+10";
> -        int resScale = -5;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_CEILING);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: local variable exponent is equal to zero
> -     */
> -    public void testDivideExpEqualsZero() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = -15;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = 10;
> -        String c = "1.64769459009933764189139568605273529E+40";
> -        int resScale = -5;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_CEILING);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: local variable exponent is greater than zero
> -     */
> -    public void testDivideExpGreaterZero() {
> -        String a = "1231212478987482988429808779810457634781384756794987";
> -        int aScale = -15;
> -        String b = "747233429293018787918347987234564568";
> -        int bScale = 20;
> -        String c = "1.647694590099337641891395686052735285121058381E+50";
> -        int resScale = -5;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_CEILING);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: remainder is zero
> -     */
> -    public void testDivideRemainderIsZero() {
> -        String a = "8311389578904553209874735431110";
> -        int aScale = -15;
> -        String b = "237468273682987234567849583746";
> -        int bScale = 20;
> -        String c = "3.5000000000000000000000000000000E+36";
> -        int resScale = -5;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_CEILING);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -    
> -    /**
> -     * Divide: rounding mode is ROUND_UP, result is negative
> -     */
> -    public void testDivideRoundUpNeg() {
> -        String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
> -        int aScale = -24;
> -        String b = "7472334223847623782375469293018787918347987234564568";
> -        int bScale = 13;
> -        String c = "-1.24390557635720517122423359799284E+53";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_UP);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: rounding mode is ROUND_UP, result is positive
> -     */
> -    public void testDivideRoundUpPos() {
> -        String a = "92948782094488478231212478987482988429808779810457634781384756794987";
> -        int aScale = -24;
> -        String b = "7472334223847623782375469293018787918347987234564568";
> -        int bScale = 13;
> -        String c = "1.24390557635720517122423359799284E+53";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_UP);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: rounding mode is ROUND_DOWN, result is negative
> -     */
> -    public void testDivideRoundDownNeg() {
> -        String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
> -        int aScale = -24;
> -        String b = "7472334223847623782375469293018787918347987234564568";
> -        int bScale = 13;
> -        String c = "-1.24390557635720517122423359799283E+53";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_DOWN);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: rounding mode is ROUND_DOWN, result is positive
> -     */
> -    public void testDivideRoundDownPos() {
> -        String a = "92948782094488478231212478987482988429808779810457634781384756794987";
> -        int aScale = -24;
> -        String b = "7472334223847623782375469293018787918347987234564568";
> -        int bScale = 13;
> -        String c = "1.24390557635720517122423359799283E+53";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_DOWN);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -    
> -    /**
> -     * Divide: rounding mode is ROUND_FLOOR, result is positive
> -     */
> -    public void testDivideRoundFloorPos() {
> -        String a = "92948782094488478231212478987482988429808779810457634781384756794987";
> -        int aScale = -24;
> -        String b = "7472334223847623782375469293018787918347987234564568";
> -        int bScale = 13;
> -        String c = "1.24390557635720517122423359799283E+53";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_FLOOR);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: rounding mode is ROUND_FLOOR, result is negative
> -     */
> -    public void testDivideRoundFloorNeg() {
> -        String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
> -        int aScale = -24;
> -        String b = "7472334223847623782375469293018787918347987234564568";
> -        int bScale = 13;
> -        String c = "-1.24390557635720517122423359799284E+53";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_FLOOR);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -    
> -    /**
> -     * Divide: rounding mode is ROUND_CEILING, result is positive
> -     */
> -    public void testDivideRoundCeilingPos() {
> -        String a = "92948782094488478231212478987482988429808779810457634781384756794987";
> -        int aScale = -24;
> -        String b = "7472334223847623782375469293018787918347987234564568";
> -        int bScale = 13;
> -        String c = "1.24390557635720517122423359799284E+53";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_CEILING);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: rounding mode is ROUND_CEILING, result is negative
> -     */
> -    public void testDivideRoundCeilingNeg() {
> -        String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
> -        int aScale = -24;
> -        String b = "7472334223847623782375469293018787918347987234564568";
> -        int bScale = 13;
> -        String c = "-1.24390557635720517122423359799283E+53";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_CEILING);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -    
> -    /**
> -     * Divide: rounding mode is ROUND_HALF_UP, result is positive; distance = -1
> -     */
> -    public void testDivideRoundHalfUpPos() {
> -        String a = "92948782094488478231212478987482988429808779810457634781384756794987";
> -        int aScale = -24;
> -        String b = "7472334223847623782375469293018787918347987234564568";
> -        int bScale = 13;
> -        String c = "1.24390557635720517122423359799284E+53";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_UP);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: rounding mode is ROUND_HALF_UP, result is negative; distance = -1
> -     */
> -    public void testDivideRoundHalfUpNeg() {
> -        String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
> -        int aScale = -24;
> -        String b = "7472334223847623782375469293018787918347987234564568";
> -        int bScale = 13;
> -        String c = "-1.24390557635720517122423359799284E+53";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_UP);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -    
> -    /**
> -     * Divide: rounding mode is ROUND_HALF_UP, result is positive; distance = 1
> -     */
> -    public void testDivideRoundHalfUpPos1() {
> -        String a = "92948782094488478231212478987482988798104576347813847567949855464535634534563456";
> -        int aScale = -24;
> -        String b = "74723342238476237823754692930187879183479";
> -        int bScale = 13;
> -        String c = "1.2439055763572051712242335979928354832010167729111113605E+76";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_UP);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: rounding mode is ROUND_HALF_UP, result is negative; distance = 1
> -     */
> -    public void testDivideRoundHalfUpNeg1() {
> -        String a = "-92948782094488478231212478987482988798104576347813847567949855464535634534563456";
> -        int aScale = -24;
> -        String b = "74723342238476237823754692930187879183479";
> -        int bScale = 13;
> -        String c = "-1.2439055763572051712242335979928354832010167729111113605E+76";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_UP);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -    
> -    /**
> -     * Divide: rounding mode is ROUND_HALF_UP, result is negative; equidistant
> -     */
> -    public void testDivideRoundHalfUpNeg2() {
> -        String a = "-37361671119238118911893939591735";
> -        int aScale = 10;
> -        String b = "74723342238476237823787879183470";
> -        int bScale = 15;
> -        String c = "-1E+5";
> -        int resScale = -5;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_UP);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -    
> -    /**
> -     * Divide: rounding mode is ROUND_HALF_DOWN, result is positive; distance = -1
> -     */
> -    public void testDivideRoundHalfDownPos() {
> -        String a = "92948782094488478231212478987482988429808779810457634781384756794987";
> -        int aScale = -24;
> -        String b = "7472334223847623782375469293018787918347987234564568";
> -        int bScale = 13;
> -        String c = "1.24390557635720517122423359799284E+53";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_DOWN);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: rounding mode is ROUND_HALF_DOWN, result is negative; distance = -1
> -     */
> -    public void testDivideRoundHalfDownNeg() {
> -        String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
> -        int aScale = -24;
> -        String b = "7472334223847623782375469293018787918347987234564568";
> -        int bScale = 13;
> -        String c = "-1.24390557635720517122423359799284E+53";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_DOWN);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -    
> -    /**
> -     * Divide: rounding mode is ROUND_HALF_DOWN, result is positive; distance = 1
> -     */
> -    public void testDivideRoundHalfDownPos1() {
> -        String a = "92948782094488478231212478987482988798104576347813847567949855464535634534563456";
> -        int aScale = -24;
> -        String b = "74723342238476237823754692930187879183479";
> -        int bScale = 13;
> -        String c = "1.2439055763572051712242335979928354832010167729111113605E+76";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_DOWN);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: rounding mode is ROUND_HALF_DOWN, result is negative; distance = 1
> -     */
> -    public void testDivideRoundHalfDownNeg1() {
> -        String a = "-92948782094488478231212478987482988798104576347813847567949855464535634534563456";
> -        int aScale = -24;
> -        String b = "74723342238476237823754692930187879183479";
> -        int bScale = 13;
> -        String c = "-1.2439055763572051712242335979928354832010167729111113605E+76";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_DOWN);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: rounding mode is ROUND_HALF_UP, result is negative; equidistant
> -     */
> -    public void testDivideRoundHalfDownNeg2() {
> -        String a = "-37361671119238118911893939591735";
> -        int aScale = 10;
> -        String b = "74723342238476237823787879183470";
> -        int bScale = 15;
> -        String c = "0E+5";
> -        int resScale = -5;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_DOWN);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: rounding mode is ROUND_HALF_EVEN, result is positive; distance = -1
> -     */
> -    public void testDivideRoundHalfEvenPos() {
> -        String a = "92948782094488478231212478987482988429808779810457634781384756794987";
> -        int aScale = -24;
> -        String b = "7472334223847623782375469293018787918347987234564568";
> -        int bScale = 13;
> -        String c = "1.24390557635720517122423359799284E+53";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_EVEN);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: rounding mode is ROUND_HALF_EVEN, result is negative; distance = -1
> -     */
> -    public void testDivideRoundHalfEvenNeg() {
> -        String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
> -        int aScale = -24;
> -        String b = "7472334223847623782375469293018787918347987234564568";
> -        int bScale = 13;
> -        String c = "-1.24390557635720517122423359799284E+53";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_EVEN);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -    
> -    /**
> -     * Divide: rounding mode is ROUND_HALF_EVEN, result is positive; distance = 1
> -     */
> -    public void testDivideRoundHalfEvenPos1() {
> -        String a = "92948782094488478231212478987482988798104576347813847567949855464535634534563456";
> -        int aScale = -24;
> -        String b = "74723342238476237823754692930187879183479";
> -        int bScale = 13;
> -        String c = "1.2439055763572051712242335979928354832010167729111113605E+76";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_EVEN);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: rounding mode is ROUND_HALF_EVEN, result is negative; distance = 1
> -     */
> -    public void testDivideRoundHalfEvenNeg1() {
> -        String a = "-92948782094488478231212478987482988798104576347813847567949855464535634534563456";
> -        int aScale = -24;
> -        String b = "74723342238476237823754692930187879183479";
> -        int bScale = 13;
> -        String c = "-1.2439055763572051712242335979928354832010167729111113605E+76";
> -        int resScale = -21;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_EVEN);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -
> -    /**
> -     * Divide: rounding mode is ROUND_HALF_EVEN, result is negative; equidistant
> -     */
> -    public void testDivideRoundHalfEvenNeg2() {
> -        String a = "-37361671119238118911893939591735";
> -        int aScale = 10;
> -        String b = "74723342238476237823787879183470";
> -        int bScale = 15;
> -        String c = "0E+5";
> -        int resScale = -5;
> -        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> -        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> -        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_EVEN);
> -        assertTrue("incorrect value", result.toString().equals(c));
> -        assertTrue("incorrect scale", result.scale() == resScale);
> -    }
> -}
> +/*
> + *  Copyright 2005 The Apache Software Foundation or its licensors, as applicable.
> + *
> + *  Licensed under the Apache License, Version 2.0 (the "License");
> + *  you may not use this file except in compliance with the License.
> + *  You may obtain a copy of the License at
> + *
> + *     http://www.apache.org/licenses/LICENSE-2.0
> + *
> + *  Unless required by applicable law or agreed to in writing, software
> + *  distributed under the License is distributed on an "AS IS" BASIS,
> + *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
> + *  See the License for the specific language governing permissions and
> + *  limitations under the License.
> + */
> +/**
> + * @author Elena Semukhina
> + * @version $Revision: 1.3.6.3 $
> + */
> +
> +package org.apache.harmony.tests.math;
> +
> +import junit.framework.TestCase;
> +import java.math.BigDecimal;
> +import java.math.BigInteger;
> +
> +/**
> + * Class:  java.math.BigDecimal
> + * Methods: add, subtract, multiply, divide 
> + */
> +public class BigDecimalArithmeticTest extends TestCase {
> +    /**
> +     * Add two numbers of equal positive scales
> +     */
> +    public void testAddEqualScalePosPos() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = 10;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = 10;
> +        String c = "123121247898748373566323807282924555312937.1991359555";
> +        int cScale = 10;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.add(bNumber);
> +        assertTrue("incorrect value " + result.toString(), result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == cScale);
> +    }
> +
> +    /**
> +     * Add two numbers of equal negative scales
> +     */
> +    public void testAddEqualScaleNegNeg() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = -10;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = -10;
> +        String c = "1.231212478987483735663238072829245553129371991359555E+61";
> +        int cScale = -10;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.add(bNumber);
> +        assertTrue("incorrect value " + result.toString(), result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == cScale);
> +    }
> +
> +    /**
> +     * Add two numbers of different scales; the first is positive
> +     */
> +    public void testAddDiffScalePosNeg() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = 15;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = -10;
> +        String c = "7472334294161400358170962860775454459810457634.781384756794987";
> +        int cScale = 15;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.add(bNumber);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == cScale);
> +    }
> +
> +    /**
> +     * Add two numbers of different scales; the first is negative
> +     */
> +    public void testAddDiffScaleNegPos() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = -15;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = 10;
> +        String c = "1231212478987482988429808779810457634781459480137916301878791834798.7234564568";
> +        int cScale = 10;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.add(bNumber);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == cScale);
> +    }
> +
> +    /**
> +     * Add two zeroes of different scales; the first is negative
> +     */
> +    public void testAddDiffScaleZeroZero() {
> +        String a = "0";
> +        int aScale = -15;
> +        String b = "0";
> +        int bScale = 10;
> +        String c = "0E-10";
> +        int cScale = 10;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.add(bNumber);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == cScale);
> +    }
> +
> +    /**
> +     * Subtract two numbers of equal positive scales
> +     */
> +    public void testSubtractEqualScalePosPos() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = 10;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = 10;
> +        String c = "123121247898748224119637948679166971643339.7522230419";
> +        int cScale = 10;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.subtract(bNumber);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == cScale);
> +    }
> +
> +    /**
> +     * Subtract two numbers of equal negative scales
> +     */
> +    public void testSubtractEqualScaleNegNeg() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = -10;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = -10;
> +        String c = "1.231212478987482241196379486791669716433397522230419E+61";
> +        int cScale = -10;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.subtract(bNumber);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == cScale);
> +    }
> +
> +    /**
> +     * Subtract two numbers of different scales; the first is positive
> +     */
> +    public void testSubtractDiffScalePosNeg() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = 15;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = -10;
> +        String c = "-7472334291698975400195996883915836900189542365.218615243205013";
> +        int cScale = 15;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.subtract(bNumber);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == cScale);
> +    }
> +
> +    /**
> +     * Subtract two numbers of different scales; the first is negative
> +     */
> +    public void testSubtractDiffScaleNegPos() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = -15;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = 10;
> +        String c = "1231212478987482988429808779810457634781310033452057698121208165201.2765435432";
> +        int cScale = 10;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.subtract(bNumber);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == cScale);
> +    }
> +
> +    /**
> +     * Multiply two numbers of positive scales
> +     */
> +    public void testMultiplyScalePosPos() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = 15;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = 10;
> +        String c = "92000312286217574978643009574114545567010139156902666284589309.1880727173060570190220616";
> +        int cScale = 25;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.multiply(bNumber);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == cScale);
> +    }
> +
> +    /**
> +     * Multiply two numbers of negative scales
> +     */
> +    public void testMultiplyEqualScaleNegNeg() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = -15;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = -10;
> +        String c = "9.20003122862175749786430095741145455670101391569026662845893091880727173060570190220616E+111";
> +        int cScale = -25;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.multiply(bNumber);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == cScale);
> +    }
> +
> +    /**
> +     * Multiply two numbers of different scales
> +     */
> +    public void testMultiplyDiffScalePosNeg() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = 10;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = -10;
> +        String c = "920003122862175749786430095741145455670101391569026662845893091880727173060570190220616";
> +        int cScale = 0;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.multiply(bNumber);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == cScale);
> +    }
> +
> +    /**
> +     * Multiply two numbers of different scales
> +     */
> +    public void testMultiplyDiffScaleNegPos() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = -15;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = 10;
> +        String c = "9.20003122862175749786430095741145455670101391569026662845893091880727173060570190220616E+91";
> +        int cScale = -5;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.multiply(bNumber);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == cScale);
> +    }
> +
> +    /**
> +     * Divide by zero
> +     */
> +    public void testDivideByZero() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = 15;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = BigDecimal.valueOf(0L);
> +        try {
> +            BigDecimal result = aNumber.divide(bNumber, BigDecimal.ROUND_UNNECESSARY);
> +            fail("ArithmeticException has not been caught");
> +        } catch (ArithmeticException e) {
> +            assertTrue("Improper exception message", e.getMessage().equals("division by zero"));
> +        }
> +    }
> +
> +    /**
> +     * Divide with ROUND_UNNECESSARY
> +     */
> +    public void testDivideExceptionRM() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = 15;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = 10;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        try {
> +            BigDecimal result = aNumber.divide(bNumber, BigDecimal.ROUND_UNNECESSARY);
> +            fail("ArithmeticException has not been caught");
> +        } catch (ArithmeticException e) {
> +            assertTrue("Improper exception message", e.getMessage().equals("rounding mode is ROUND_UNNECESSARY but the result is not exact"));
> +        }
> +    }
> +
> +    /**
> +     * Divide with invalid rounding mode
> +     */
> +    public void testDivideExceptionInvalidRM() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = 15;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = 10;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        try {
> +            BigDecimal result = aNumber.divide(bNumber, 100);
> +            fail("IllegalArgumentException has not been caught");
> +        } catch (IllegalArgumentException e) {
> +            assertTrue("Improper exception message", e.getMessage().equals("invalid rounding mode"));
> +        }
> +    }
> +
> +    /**
> +     * Divide: local variable exponent is less than zero
> +     */
> +    public void testDivideExpLessZero() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = 15;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = 10;
> +        String c = "1.64770E+10";
> +        int resScale = -5;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_CEILING);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: local variable exponent is equal to zero
> +     */
> +    public void testDivideExpEqualsZero() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = -15;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = 10;
> +        String c = "1.64769459009933764189139568605273529E+40";
> +        int resScale = -5;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_CEILING);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: local variable exponent is greater than zero
> +     */
> +    public void testDivideExpGreaterZero() {
> +        String a = "1231212478987482988429808779810457634781384756794987";
> +        int aScale = -15;
> +        String b = "747233429293018787918347987234564568";
> +        int bScale = 20;
> +        String c = "1.647694590099337641891395686052735285121058381E+50";
> +        int resScale = -5;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_CEILING);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: remainder is zero
> +     */
> +    public void testDivideRemainderIsZero() {
> +        String a = "8311389578904553209874735431110";
> +        int aScale = -15;
> +        String b = "237468273682987234567849583746";
> +        int bScale = 20;
> +        String c = "3.5000000000000000000000000000000E+36";
> +        int resScale = -5;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_CEILING);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +    
> +    /**
> +     * Divide: rounding mode is ROUND_UP, result is negative
> +     */
> +    public void testDivideRoundUpNeg() {
> +        String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
> +        int aScale = -24;
> +        String b = "7472334223847623782375469293018787918347987234564568";
> +        int bScale = 13;
> +        String c = "-1.24390557635720517122423359799284E+53";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_UP);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: rounding mode is ROUND_UP, result is positive
> +     */
> +    public void testDivideRoundUpPos() {
> +        String a = "92948782094488478231212478987482988429808779810457634781384756794987";
> +        int aScale = -24;
> +        String b = "7472334223847623782375469293018787918347987234564568";
> +        int bScale = 13;
> +        String c = "1.24390557635720517122423359799284E+53";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_UP);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: rounding mode is ROUND_DOWN, result is negative
> +     */
> +    public void testDivideRoundDownNeg() {
> +        String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
> +        int aScale = -24;
> +        String b = "7472334223847623782375469293018787918347987234564568";
> +        int bScale = 13;
> +        String c = "-1.24390557635720517122423359799283E+53";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_DOWN);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: rounding mode is ROUND_DOWN, result is positive
> +     */
> +    public void testDivideRoundDownPos() {
> +        String a = "92948782094488478231212478987482988429808779810457634781384756794987";
> +        int aScale = -24;
> +        String b = "7472334223847623782375469293018787918347987234564568";
> +        int bScale = 13;
> +        String c = "1.24390557635720517122423359799283E+53";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_DOWN);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +    
> +    /**
> +     * Divide: rounding mode is ROUND_FLOOR, result is positive
> +     */
> +    public void testDivideRoundFloorPos() {
> +        String a = "92948782094488478231212478987482988429808779810457634781384756794987";
> +        int aScale = -24;
> +        String b = "7472334223847623782375469293018787918347987234564568";
> +        int bScale = 13;
> +        String c = "1.24390557635720517122423359799283E+53";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_FLOOR);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: rounding mode is ROUND_FLOOR, result is negative
> +     */
> +    public void testDivideRoundFloorNeg() {
> +        String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
> +        int aScale = -24;
> +        String b = "7472334223847623782375469293018787918347987234564568";
> +        int bScale = 13;
> +        String c = "-1.24390557635720517122423359799284E+53";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_FLOOR);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +    
> +    /**
> +     * Divide: rounding mode is ROUND_CEILING, result is positive
> +     */
> +    public void testDivideRoundCeilingPos() {
> +        String a = "92948782094488478231212478987482988429808779810457634781384756794987";
> +        int aScale = -24;
> +        String b = "7472334223847623782375469293018787918347987234564568";
> +        int bScale = 13;
> +        String c = "1.24390557635720517122423359799284E+53";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_CEILING);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: rounding mode is ROUND_CEILING, result is negative
> +     */
> +    public void testDivideRoundCeilingNeg() {
> +        String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
> +        int aScale = -24;
> +        String b = "7472334223847623782375469293018787918347987234564568";
> +        int bScale = 13;
> +        String c = "-1.24390557635720517122423359799283E+53";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_CEILING);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +    
> +    /**
> +     * Divide: rounding mode is ROUND_HALF_UP, result is positive; distance = -1
> +     */
> +    public void testDivideRoundHalfUpPos() {
> +        String a = "92948782094488478231212478987482988429808779810457634781384756794987";
> +        int aScale = -24;
> +        String b = "7472334223847623782375469293018787918347987234564568";
> +        int bScale = 13;
> +        String c = "1.24390557635720517122423359799284E+53";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_UP);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: rounding mode is ROUND_HALF_UP, result is negative; distance = -1
> +     */
> +    public void testDivideRoundHalfUpNeg() {
> +        String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
> +        int aScale = -24;
> +        String b = "7472334223847623782375469293018787918347987234564568";
> +        int bScale = 13;
> +        String c = "-1.24390557635720517122423359799284E+53";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_UP);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +    
> +    /**
> +     * Divide: rounding mode is ROUND_HALF_UP, result is positive; distance = 1
> +     */
> +    public void testDivideRoundHalfUpPos1() {
> +        String a = "92948782094488478231212478987482988798104576347813847567949855464535634534563456";
> +        int aScale = -24;
> +        String b = "74723342238476237823754692930187879183479";
> +        int bScale = 13;
> +        String c = "1.2439055763572051712242335979928354832010167729111113605E+76";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_UP);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: rounding mode is ROUND_HALF_UP, result is negative; distance = 1
> +     */
> +    public void testDivideRoundHalfUpNeg1() {
> +        String a = "-92948782094488478231212478987482988798104576347813847567949855464535634534563456";
> +        int aScale = -24;
> +        String b = "74723342238476237823754692930187879183479";
> +        int bScale = 13;
> +        String c = "-1.2439055763572051712242335979928354832010167729111113605E+76";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_UP);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +    
> +    /**
> +     * Divide: rounding mode is ROUND_HALF_UP, result is negative; equidistant
> +     */
> +    public void testDivideRoundHalfUpNeg2() {
> +        String a = "-37361671119238118911893939591735";
> +        int aScale = 10;
> +        String b = "74723342238476237823787879183470";
> +        int bScale = 15;
> +        String c = "-1E+5";
> +        int resScale = -5;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_UP);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +    
> +    /**
> +     * Divide: rounding mode is ROUND_HALF_DOWN, result is positive; distance = -1
> +     */
> +    public void testDivideRoundHalfDownPos() {
> +        String a = "92948782094488478231212478987482988429808779810457634781384756794987";
> +        int aScale = -24;
> +        String b = "7472334223847623782375469293018787918347987234564568";
> +        int bScale = 13;
> +        String c = "1.24390557635720517122423359799284E+53";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_DOWN);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: rounding mode is ROUND_HALF_DOWN, result is negative; distance = -1
> +     */
> +    public void testDivideRoundHalfDownNeg() {
> +        String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
> +        int aScale = -24;
> +        String b = "7472334223847623782375469293018787918347987234564568";
> +        int bScale = 13;
> +        String c = "-1.24390557635720517122423359799284E+53";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_DOWN);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +    
> +    /**
> +     * Divide: rounding mode is ROUND_HALF_DOWN, result is positive; distance = 1
> +     */
> +    public void testDivideRoundHalfDownPos1() {
> +        String a = "92948782094488478231212478987482988798104576347813847567949855464535634534563456";
> +        int aScale = -24;
> +        String b = "74723342238476237823754692930187879183479";
> +        int bScale = 13;
> +        String c = "1.2439055763572051712242335979928354832010167729111113605E+76";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_DOWN);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: rounding mode is ROUND_HALF_DOWN, result is negative; distance = 1
> +     */
> +    public void testDivideRoundHalfDownNeg1() {
> +        String a = "-92948782094488478231212478987482988798104576347813847567949855464535634534563456";
> +        int aScale = -24;
> +        String b = "74723342238476237823754692930187879183479";
> +        int bScale = 13;
> +        String c = "-1.2439055763572051712242335979928354832010167729111113605E+76";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_DOWN);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: rounding mode is ROUND_HALF_UP, result is negative; equidistant
> +     */
> +    public void testDivideRoundHalfDownNeg2() {
> +        String a = "-37361671119238118911893939591735";
> +        int aScale = 10;
> +        String b = "74723342238476237823787879183470";
> +        int bScale = 15;
> +        String c = "0E+5";
> +        int resScale = -5;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_DOWN);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: rounding mode is ROUND_HALF_EVEN, result is positive; distance = -1
> +     */
> +    public void testDivideRoundHalfEvenPos() {
> +        String a = "92948782094488478231212478987482988429808779810457634781384756794987";
> +        int aScale = -24;
> +        String b = "7472334223847623782375469293018787918347987234564568";
> +        int bScale = 13;
> +        String c = "1.24390557635720517122423359799284E+53";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_EVEN);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: rounding mode is ROUND_HALF_EVEN, result is negative; distance = -1
> +     */
> +    public void testDivideRoundHalfEvenNeg() {
> +        String a = "-92948782094488478231212478987482988429808779810457634781384756794987";
> +        int aScale = -24;
> +        String b = "7472334223847623782375469293018787918347987234564568";
> +        int bScale = 13;
> +        String c = "-1.24390557635720517122423359799284E+53";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_EVEN);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +    
> +    /**
> +     * Divide: rounding mode is ROUND_HALF_EVEN, result is positive; distance = 1
> +     */
> +    public void testDivideRoundHalfEvenPos1() {
> +        String a = "92948782094488478231212478987482988798104576347813847567949855464535634534563456";
> +        int aScale = -24;
> +        String b = "74723342238476237823754692930187879183479";
> +        int bScale = 13;
> +        String c = "1.2439055763572051712242335979928354832010167729111113605E+76";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_EVEN);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: rounding mode is ROUND_HALF_EVEN, result is negative; distance = 1
> +     */
> +    public void testDivideRoundHalfEvenNeg1() {
> +        String a = "-92948782094488478231212478987482988798104576347813847567949855464535634534563456";
> +        int aScale = -24;
> +        String b = "74723342238476237823754692930187879183479";
> +        int bScale = 13;
> +        String c = "-1.2439055763572051712242335979928354832010167729111113605E+76";
> +        int resScale = -21;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_EVEN);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +
> +    /**
> +     * Divide: rounding mode is ROUND_HALF_EVEN, result is negative; equidistant
> +     */
> +    public void testDivideRoundHalfEvenNeg2() {
> +        String a = "-37361671119238118911893939591735";
> +        int aScale = 10;
> +        String b = "74723342238476237823787879183470";
> +        int bScale = 15;
> +        String c = "0E+5";
> +        int resScale = -5;
> +        BigDecimal aNumber = new BigDecimal(new BigInteger(a), aScale);
> +        BigDecimal bNumber = new BigDecimal(new BigInteger(b), bScale);
> +        BigDecimal result = aNumber.divide(bNumber, resScale, BigDecimal.ROUND_HALF_EVEN);
> +        assertTrue("incorrect value", result.toString().equals(c));
> +        assertTrue("incorrect scale", result.scale() == resScale);
> +    }
> +}
> 
> 
> 

-- 

Tim Ellison (t.p.ellison@gmail.com)
IBM Java technology centre, UK.