• Post Reply Bookmark Topic Watch Topic
  • New Topic

Scientific Notation for Calculator

 
Abhijeet Roy
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Abhik Sarkar
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Abhijeet,
You might find what you are looking for here...
Best regards,
Abhik.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!