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

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
```

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

I need to get some numbers..

eg.. 0.012333 or 0.000000000000000000000000

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

membership

This solution is only available to members.

To access this solution, you must be a member of Experts Exchange.

(I guess you must want to since deliberately reducing the precision rarely makes sense)

ASKER

I am getting 0.00 which I dont need

What are you going to do with it?

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

who can I prevent the method varRaidus = Function.calcRadioActiveRa

from outputing the sceintific format?

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

ASKER

This number is sceintifc 1.1638387640158259E-107

I am looking for a standard value or double behind it

I am looking for a standard value or double behind it

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

http://download.oracle.com/javase/6/docs/api/java/text/DecimalFormat.html

see the following for options to format a double

http://helpdesk.objects.com.au/java/how-to-format-a-double-as-a-string

http://helpdesk.objects.com.au/java/how-to-format-a-double-as-a-string

if( abs( varRaidus ) < threshold )

varRaidus = 0.0;