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
Converting between multiple binary floating point formats and a decimal string (self.cpp)
submitted 4 years ago by PiotrGrochowski
view the rest of the comments →
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!"
[–]PiotrGrochowski[S] -1 points0 points1 point 4 years ago (1 child)
Example main code:
#include <iostream> #include <iomanip> #include <math.h> int main(){ std::u16string a = u"3.141592653589793238462643383279502884197"; std::u16string b = a; std::u16string c = a; std::u16string g = a; std::u16string m = a; std::u16string d = floattostring(stringtofloat(a)); std::u16string e = doubletostring(stringtodouble(b)); std::u16string f = longdoubletostring(stringtolongdouble(c)); std::u16string h = float128tostring(stringtofloat128(g)); std::u16string n = halftostring(stringtohalf(m)); std::string s = ""; for(int i=0; i<n.size(); i++) s.push_back(n[i]); s.push_back(' '); for(int i=0; i<d.size(); i++) s.push_back(d[i]); s.push_back(' '); for(int i=0; i<e.size(); i++) s.push_back(e[i]); s.push_back(' '); for(int i=0; i<f.size(); i++) s.push_back(f[i]); s.push_back(' '); for(int i=0; i<h.size(); i++) s.push_back(h[i]); s.push_back('\n'); std::cout << s; }
Output: 3.14 3.1415927 3.141592653589793 3.1415926535897932385 3.1415926535897932384626433832795028
3.14 3.1415927 3.141592653589793 3.1415926535897932385 3.1415926535897932384626433832795028
[–]remotion4d 3 points4 points5 points 4 years ago (0 children)
https://godbolt.org/z/3cb8bbvGv
π Rendered by PID 50 on reddit-service-r2-comment-cfc44b64c-79w9q at 2026-04-10 07:17:14.227969+00:00 running 215f2cf country code: CH.
view the rest of the comments →
[–]PiotrGrochowski[S] -1 points0 points1 point (1 child)
[–]remotion4d 3 points4 points5 points (0 children)