It's possibly a very stupid question, but I've been searching for a whole day and I couldn't get an answer...
Let's say I have a double-precision floating point literal: 5.21
. Calling Double.toString( 5.21 )
in Java yields the string "5.21"
.
Now, let's say we have Java, but without toString
and valueOf
, nor can I format it with String.format
or just by concatenation. How would I be able to convert my number to a string, assuming that I only have the binary representation?
More specifically, how do Double.toString
and dtoa
exactly work: how can I write my own toString
/dtoa
function (assuming we're dealing with IEEE 754 double-precision floating points)?