I am trying to implement http://www.exploringbinary.com/correct-decimal-to-floating-point-using-big-integers/
I have read through it quite a few times and feel very comfortable with it. The first step is assuming the value is in a string format. My implementation is assuming that the value is in a double format.
Is it possible to obtain the number of digits that make up the fractional portion of a float/double?
For example, the value 3.24325 (I hope that cannot be represented exactly in binary, because I just randomly chose it). I would want to know that the decimal portion is 5 digits long so that I can continue with the algorithm in the link above.
Using something like modf
results in what appears to be a correct fractional value at first glance, but its actually rounded (assuming the fractional portion cannot be exactly represented in binary). Subtracting a typecasted int of the original value from the original value results in the same rounded decimal. Recording the value in a string with sprintf results in a similar issue (I believe), but I havent had enough time to confirm that - I just started playing with it.
Is there any solution to step 1 of the algorithm in the link above?
Thank you.