• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java code to convert exponential to standard format  RSS feed

 
Adarsh Dhingra
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I have the requirement such that there will be one input, which may be like 2.01E+5 i.e. exponential form or it may be like 3.7788. If it is in exponential form I want it to return value as 2010000 etc. and if it is in decimal such as 3.7788 then it should return it as it is with as many decimal places as in the input and should not add any redundant zeroes at the end of decimal like 3.228000; it should be like 3.228...
 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Adarsh Dhingra wrote:I have the requirement such that there will be one input, which may be like 2.01E+5 i.e. exponential form or it may be like 3.7788. If it is in exponential form I want it to return value as 2010000 etc. and if it is in decimal such as 3.7788 then it should return it as it is with as many decimal places as in the input and should not add any redundant zeroes at the end of decimal like 3.228000; it should be like 3.228...

Have a look at BigDecimal. I suspect it has all the stuff you need to do it one line.

Winston
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!