question: public void testMultiplyMathContextDiffScalePosNeg ( ) { String a = "987667796597975765768768767866756808779810457634781384756794987" ; int aScale = 100 ; String b = "747233429293018787918347987234564568" ; int bScale = - 70 ; String c = "7.3801839465418518653942222612429081498248509257207477E+68" ; int cScale = - 16 ; BigDecimal aNumber = new BigDecimal ( new BigInteger ( a ) , aScale ) ; BigDecimal bNumber = new BigDecimal ( new BigInteger ( b ) , bScale ) ; MathContext mc = new MathContext ( 53 , RoundingMode . HALF_UP ) ; BigDecimal result = aNumber . multiply ( bNumber , mc ) ; assertEquals ( "incorrect value" , c , result . toString ( ) ) ; assertEquals ( "incorrect scale" , cScale , result . scale ( ) ) ; }
target:  Multiply two numbers of different scales using MathContext