Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Java (http://www.velocityreviews.com/forums/f30-java.html)
-   -   converting exponential number to float number (http://www.velocityreviews.com/forums/t389985-converting-exponential-number-to-float-number.html)

ruds 01-10-2007 11:10 AM

converting exponential number to float number
 
Can anyone tell me how do i convert a string contianing exponential
number to decimal/float number?
Is there any built in method for doing this?


Patricia Shanahan 01-10-2007 11:19 AM

Re: converting exponential number to float number
 
ruds wrote:
> Can anyone tell me how do i convert a string contianing exponential
> number to decimal/float number?
> Is there any built in method for doing this?
>


Can you give an example of a string you want to convert?

Patricia

Eric Sosman 01-10-2007 01:31 PM

Re: converting exponential number to float number
 
ruds wrote:
> Can anyone tell me how do i convert a string contianing exponential
> number to decimal/float number?
> Is there any built in method for doing this?


If I understand what you are asking for,

double d = Double.parseDouble("1.23e+4");

fills the bill.

--
Eric Sosman
esosman@acm-dot-org.invalid


Daniel Pitts 01-10-2007 10:15 PM

Re: converting exponential number to float number
 

Eric Sosman wrote:
> ruds wrote:
> > Can anyone tell me how do i convert a string contianing exponential
> > number to decimal/float number?
> > Is there any built in method for doing this?

>
> If I understand what you are asking for,
>
> double d = Double.parseDouble("1.23e+4");
>
> fills the bill.
>
> --
> Eric Sosman
> esosman@acm-dot-org.invalid


Or, if its a constant string, why bother parsing at all?

double d = 1.23e+4;



All times are GMT. The time now is 05:35 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.