In Java we have Integer.toBinaryString(int) which returns binary string representing the integer.How to represent for numbers larger than Integer.MAX_VALUE? For example,double d = Math.pow(10,50),how to obtain binary string for d ?
Note that the java.lang.Double class has the doubleToLongBits method that returns a long value and that the Long class has the toBinaryString method. You really should have a copy of the JavaDocs unpacked on your hard drive and get familiar with using it - it saves lots of time. Bill
Joined: Feb 28, 2005
I think it won't handle the big number Math.pow(10,100).The only option is now to use,java.math.BigInteger.
Author and all-around good cowpoke
Joined: Mar 22, 2000
The doubleToLongBits method will handle any double - the reason being that it simply takes the 8 bytes of a double and returns them as 8 bytes of a long. Thus the bits represent the entire IEEE 754 floating point double - sign, exponent and mantissa. Bill