• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to avoid -e exponential representation in servlet

 
sakthi vadivel
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ranch.

Anybody tell me the API to convert exponential number to ordinary number in servlet.

thanks in advance.
sakthi
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
(Moved to a more general forum, since the answer has nothing to do with servlets.)

What do you mean by "convert" - what data type and format does the input have, and what data type and format should the output have? Integer? String? Something else? Can you give an example of input and desired output?
 
sakthi vadivel
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry i forget to mention that...

I want to display the double value without exponential representation. whether string or long or double....
 
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
Use a DecimalFormat object to convert your double to a String:

Lookup the documentation for DecimalFormat.
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Something like the following should do the trick. Be sure to read the javadocs of the toPlainString method.
 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you know the likely range of the values to display, try the %f tags. They work with the Formatter#format, PrintStream#format, PrintStream#print(ln) and String#format methods.
 
sakthi vadivel
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thankyou folks...

i got solution new java.math.BigDecimal(d).toBigInteger()

because toPlainString() is undefined for the BigDecimal....

thanks to all....
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you need new glasses. toPlainString() is undefined for BigInteger; it is most definitely defined for BigDecimal.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic