# Scientific Notation for Calculator

Abhijeet Roy

Greenhorn

Posts: 3

posted 13 years ago

Hello All

I am working on a calculator project and am trying to format the results of my calculations so that it displays just like the Windows calculator, eg. 99999999999999999999999999999999 * 9 should be = 8.9999999999999999999999999999999e+32.

My calculations are done using BigDecimal (for precision reasons) and my result needs to be a String (for display).

Can anyone please tell me how I can format the results of the following calculation:

BigDecimal num1=new java.math.BigDecimal("99999999999999999999999999999999");

BigDecimal num2=new java.math.BigDecimal("9");

BigDecimal numRes=new java.math.BigDecimal("0");

numRes = num1.multiply(num2);

After the calculation i need the result in a String.

Thanks!

I am working on a calculator project and am trying to format the results of my calculations so that it displays just like the Windows calculator, eg. 99999999999999999999999999999999 * 9 should be = 8.9999999999999999999999999999999e+32.

My calculations are done using BigDecimal (for precision reasons) and my result needs to be a String (for display).

Can anyone please tell me how I can format the results of the following calculation:

BigDecimal num1=new java.math.BigDecimal("99999999999999999999999999999999");

BigDecimal num2=new java.math.BigDecimal("9");

BigDecimal numRes=new java.math.BigDecimal("0");

numRes = num1.multiply(num2);

After the calculation i need the result in a String.

Thanks!