Do java.lang.Double.toString () and java.lang.Double.parse Is a double-sided move safe?

I was not able to find a quick answer to this question for Java from some kind of googling, and I accidentally wonder:

For any non NaN double d , Double.parseDouble(Double.toString(d)) == d ?

+4
source share
1 answer

A (not very fast) test shows that it:

 @Test public void testDouble() { for (double d = Double.MIN_VALUE; d<Double.MAX_VALUE; d=d+0.00001) { assertTrue("double does not match!", Double.parseDouble(Double.toString(d)) == d); } } 

This has been working on my machine for a while, and it hasn't worked yet!

+2
source

All Articles