aspose file tools*
The moose likes Java in General and the fly likes Large Bit Stream Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Large Bit Stream" Watch "Large Bit Stream" New topic
Author

Large Bit Stream

Arjunkumar Shastry
Ranch Hand

Joined: Feb 28, 2005
Posts: 986
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 ?


Namma Suvarna Karnataka
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
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
Arjunkumar Shastry
Ranch Hand

Joined: Feb 28, 2005
Posts: 986
I think it won't handle the big number Math.pow(10,100).The only option is now to use,java.math.BigInteger.
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12803
    
    5
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Large Bit Stream