Convert String to Double while maintaining content

Asked

Viewed 6,279 times

1

I need Java to convert a String which has a binary value (Ex: "0111010") for a double. I tested:

String teste = "101010101";
double number = Double.parseDouble(teste);
System.out.println("The number is: " + number);

But the output is a completely different hexadecimal number. I need the output to be the same as the String. The double can even put point somewhere, no problem, but need to keep the same binary and in the same order.

1 answer

2


  • Of course, important detail that I didn’t remember. That’s it! Thank you.

  • I made no attempt to turn the String in double because that number would be invalid. If it were for an integer it would give and has function ready for it. It also has to double, but the text needs to be in format that can be converted correctly.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.