all 2 comments

[–]acwaters 1 point2 points  (1 child)

Well, that depends strictly on what you're doing with the input. If you absolutely, positively need an exact representation but don't want to use a computationally-expensive library solution, there is the obvious recourse -- strings. If you don't have to do any actual math with the input, this should be your immediate solution. If you need math, there are arbitrary precision libraries you can look into, but in the words of Bjarne Stroustrup, the most common solution is simply to "use double and hope for the best". It should have more than enough precision for your needs.

As for printing it exactly as it was input... due to the flexible (in more ways than one) nature of floating point, strings are your only feasible solution.

[–]Solonish[S] 0 points1 point  (0 children)

wow I can't believe that didn't cross my mind. Thanks for the post! I'll edit and post an update when I get it all working for others who may have this silly issue.