I want to convert a string representing the mantissa portion of a IEEE754 double. Cannot find if there is such a conversion method in Java, in order to avoid manually adding 1 + 1/2 + 1/4 + 1/8 etc.
|0100000011001010000111110000000000000000000000000000000000000000
--> 13374 in IEEE754
|------------1010000111110000000000000000000000000000000000000000
--> mantissa part
| 1.1010000111110000000000000000000000000000000000000000
--> restoring fixed value 1
String s = "1.1010000111110000000000000000000000000000000000000000"
double mant10 = Double.readFromFloatBinary(s); // does such method exists in Java?
Yes, there are ways to read from a binary representation. But you don't have a representation in an IEEE format.
I would ignore the period and read as a
BigInteger
base2, then create a value to divide by also usingBigInteger
: