• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Scientific Notation for Calculator

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Abhijeet,
You might find what you are looking for here...
Best regards,
Abhik.
 
reply
    Bookmark Topic Watch Topic
  • New Topic