Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

how to convert mantissa presentation to double  RSS feed

 
Meir Yan
Ranch Hand
Posts: 599
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all
im getting from as input mantissa presentation that i know its double it looks like this : 8.0E-4
i need to convert it to its double presentation that i know is 0.0008
how can it be done in java ?
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16028
87
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use class java.text.DecimalFormat to format decimal numbers in many different ways. Look it up in the API documentation.
 
Ronald Schild
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What would be the best pattern to convert any scientific notation to normal? I've been playing with "####################.###################", it seems to work but feels so random.
 
Campbell Ritchie
Marshal
Posts: 55704
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The System.out.printf method with "%.4f" (or similar) as a format String might work as well.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!