Is there any way to convert a Long data type to Double or double?
For example, I need to convert 15552451L to a
Are you looking for the binary conversion?
double result = Double.longBitsToDouble(15552451L);
This will give you the double with the same bit pattern as the long literal.
Binary or hexadecimal literals will come in handy, here. Here are some examples.
double nan = Double.longBitsToDouble(0xfff0000000000001L);
double positiveInfinity = Double.longBitsToDouble(0x7ff0000000000000L);
double positiveInfinity = Double.longBitsToDouble(0xfff0000000000000L);
(See Double.longBitsToDouble(long))
You also can get the long back with
long bits = Double.doubleToRawLongBits(Double.NaN);
(See Double.doubleToRawLongBits(double))