Link to home
Start Free TrialLog in
Avatar of ZURINET
ZURINET

asked on

Math round double number (convert from scientific to real number)

Hi all

I have a mathematical method in java
that returns the following value = 1.1638387640158259E-107
How can I convert this number to double
eg..  0.000000000

Thanks in advance..

See code below for example method
varRaidus  = Function.calcRadioActiveRadius(t, startRadius, rateOfDecay);
gives 1.1638387640158259E-107
Which I cannot do any thing with.. 
expected 0.000000000

Open in new window

Avatar of phoffric
phoffric

How about taking the absolute value of varRaidus and compare less than a threshold.
if( abs( varRaidus ) < threshold )
    varRaidus = 0.0;
Avatar of ZURINET

ASKER

I am not expecting the value 0.0...
I need to get some numbers..

eg.. 0.012333 or 0.0000000000000000000000000333

I need to get ride of the  "E-107"

The value I am curently getting is a sceintifc number..
which i dont need
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
(I guess you must want to since deliberately reducing the precision rarely makes sense)
Avatar of ZURINET

ASKER

I am getting 0.00 which I dont need
What are you going to do with it?
Avatar of ZURINET

ASKER

Another question is

who can I prevent the method varRaidus  = Function.calcRadioActiveRadius(t, startRadius, rateOfDecay);
from outputing the sceintific format?

Given that the 3 variable are t = int  startRadius = double, rateOfDecay = double
Avatar of ZURINET

ASKER

This number is sceintifc 1.1638387640158259E-107
I am looking for a standard value or double behind it

Avatar of ZURINET

ASKER

Sorry I forgot my maths
You should use DecimalFormat to format a float to string.
  http://download.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html