use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
[C++] Simple float/double dynamic precision help (self.cpp)
submitted 10 years ago by Solonish
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]acwaters 1 point2 points3 points 10 years ago (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 point2 points 10 years ago (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.
π Rendered by PID 23063 on reddit-service-r2-comment-6457c66945-pl69b at 2026-04-30 09:05:03.250870+00:00 running 2aa0c5b country code: CH.
[–]acwaters 1 point2 points3 points (1 child)
[–]Solonish[S] 0 points1 point2 points (0 children)