fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. System.out.println(convert("0.25"));
  13. System.out.println(convert("-0.25"));
  14.  
  15. }
  16.  
  17. public static String convert(String input) {
  18.  
  19. double number = Double.parseDouble(input);
  20. long longBits = Double.doubleToLongBits(number);
  21. String result = Long.toBinaryString(longBits);
  22.  
  23. return result;
  24. }
  25.  
  26. }
Success #stdin #stdout 0.06s 2841600KB
stdin
Standard input is empty
stdout
11111111010000000000000000000000000000000000000000000000000000
1011111111010000000000000000000000000000000000000000000000000000