• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to convert mantissa presentation to double

 
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
Saloon Keeper
Posts: 15216
36
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
Sheriff
Posts: 48652
56
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic