This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills: The software developer's life manual and have John Sonmez on-line!
See this thread for details.
Win a copy of Soft Skills: The software developer's life manual this week in the Jobs Discussion forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Large Bit Stream

 
Arjunkumar Shastry
Ranch Hand
Posts: 986
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13044
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 986
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13044
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic