# Convert Int to Doubel value without exponents and decimal value.

• November 1st, 2011, 08:06 PM
project25_java
Convert Int to Doubel value without exponents and decimal value.
Hi,

I want to convert int value to double value without any exponents and decimal values.
I have following int number like to convert this to double. Because server side code is expecting data type in double.

Code :

```integer intNum = 285292746; double dNumber = Double.parseDouble(Integer.ToString(intNum));```

It returns double number with exponential and decimal. Type return should be Double.
Code :

` dNumber = 2.85292746E8`

I need to pass double value to server code but in plain format like 285292746 or it can accept 285292746.000 but no E /Exponential value and decimal values.

Code :

```public class prog2 { public static void main(String args[]) {   int intNum = 285292746;   double dNumber = Double.parseDouble(Integer.ToString(intNum));   String str = Double.toString(dNumber); Double d = new Double(str); double dd = d.doubleValue();   DecimalFormat formatter = new DecimalFormat("#.000000"); System.out.println(formatter.format(dd)); } }```

Eventually i need to pass this double value to

JAXBElement<Double> fileId = _of.CreateFileId(Double);

Please give me some tips or ideas. How should I handle it.
• November 1st, 2011, 09:36 PM
csharp100
Re: Convert Int to Doubel value without exponents and decimal value.
we see that Math.floor(double a) turns the provided double into the equivalent double with no decimal component..

Math.floor(10.99999) returns 10.0 (as a double)

which you can then convert to an integer simply by casting:

int myInt = (int) Math.floor(10.99999);
//myInt is equal to 10

similarly, the round() function can be looked up.. round rounds 10.0 to 10.49999... down to 10.0, and 10.5 to 10.999999... up to 11.0

there is another related operation, ceiling, that rounds any double up to the next whole double with no decimal component, so 10.49999, becomes 11.0
It is symantically equivalent to :
Math.floor(double a +1)