Search code examples
javamatlabdecimaldouble-precision

java: how can I convert double precision numbers to decimal


I want to convert double precision numbers to decimal .

for example I have 23.43, the double value would be (using matlab) : 174 71 255 122 20 110 55 64 now having this how can I write a java program that gives me 23.43 ?

and here is the calculation of double precision in matlab :

MATLAB constructs the double data type according to IEEE Standard 754 for double precision. Any value stored as a double requires 64 bits, formatted as shown in the table below:

Bits Usage

63 Sign (0 = positive, 1 = negative)

62 to 52 Exponent, biased by 1023

51 to 0 Fraction f of the number 1.f


Solution

  • long l = Double.doubleToLongBits(double);
    double d = Double.longBitsToDouble(long);