From 47733e4e29c029abf3776f0b97a0e27f9ac81d54 Mon Sep 17 00:00:00 2001 From: Anthony Calandra Date: Sat, 22 Feb 2020 16:27:51 -0500 Subject: [PATCH] Added C++20 mathematical constants. --- CPP20.md | 8 ++++++++ README.md | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/CPP20.md b/CPP20.md index 033fce0..00590bb 100644 --- a/CPP20.md +++ b/CPP20.md @@ -22,6 +22,7 @@ C++20 includes the following new library features: - [synchronized buffered outputstream](#synchronized-buffered-outputstream) - [std::span](#stdspan) - [bit operations](#bit-operations) +- [math constants](#math-constants) ## C++20 Language Features @@ -418,6 +419,13 @@ std::popcount(1u); // 1 std::popcount(0b1111'0000u); // 4 ``` +### math constants +Mathematical constants including PI, Euler's number, etc. defined in the `` header. +```c++ +std::numbers::pi; // 3.14159... +std::numbers::e; // 2.71828... +``` + ## Acknowledgements * [cppreference](http://en.cppreference.com/w/cpp) - especially useful for finding examples and documentation of new library features. * [C++ Rvalue References Explained](http://thbecker.net/articles/rvalue_references/section_01.html) - a great introduction I used to understand rvalue references, perfect forwarding, and move semantics. diff --git a/README.md b/README.md index c5bd5ea..adef75b 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,7 @@ C++20 includes the following new library features: - [synchronized buffered outputstream](#synchronized-buffered-outputstream) - [std::span](#stdspan) - [bit operations](#bit-operations) +- [math constants](#math-constants) C++17 includes the following new language features: - [template argument deduction for class templates](#template-argument-deduction-for-class-templates) @@ -510,6 +511,13 @@ std::popcount(1u); // 1 std::popcount(0b1111'0000u); // 4 ``` +### math constants +Mathematical constants including PI, Euler's number, etc. defined in the `` header. +```c++ +std::numbers::pi; // 3.14159... +std::numbers::e; // 2.71828... +``` + ## C++17 Language Features ### Template argument deduction for class templates