/****************************************************************************** * This program demonstrates a function to compute π * * Copyright © 2017 Richard Lesh. All rights reserved. *****************************************************************************/ #include #include #include #include #include #include #include std::locale utf8loc(std::locale(), new std::codecvt_utf8); using namespace std; double calcpi() noexcept { return 2.0 * acos(0.0); } int main(int argc, char **argv) { setlocale(LC_ALL, "en_US.UTF-8"); wcout.imbue(utf8loc); wcin.imbue(utf8loc); double const PI = calcpi(); wcout << fmt::format(L"PI: {0:.15f}", PI) << endl; wcout << fmt::format(L"abs(PI - π): {0:.10e}", abs(PI - M_PI)) << endl; return 0; }