Bug? in Long.valueOf(String, radix)
Hi everyone,
I am currently programming a genetic algorithm(GA) for my work and a came across a small difficulty.
GA usually use binary strings for their internal operations. So I decided to use Double.toLongBits() to convert a double into a long and then Long.toBinaryString() to get a String to work with.
Here is the part of the code that confuses me a bit.
double d = -2.33;
long bit = Double.toLongBits(d);
String s = Long.toBinaryString(bit);
//now try and convert it back Binary Strings have radix 2
long back = Long.valueOf(s,2);
This last line always throws a NumberFormatException.
The code was only intended to show me that the conversion always works correctly in both directions.
If I use 2.33 instead of -2.33 it works.
Am I making a mistake or is this a bug?
Thanks for any remarks!

