Conversion from Long to Double in Java

Harry picture Harry · Sep 16, 2010 · Viewed 210.1k times · Source

Is there any way to convert a Long data type to Double or double?

For example, I need to convert 15552451L to a double data type.

Answer

YoK picture YoK · Sep 16, 2010

You could simply do :

double d = (double)15552451L;

Or you could get double from Long object as :

Long l = new Long(15552451L);
double d = l.doubleValue();