Created
July 6, 2014 19:24
-
-
Save ThePhD/4e562da1511935513b4a to your computer and use it in GitHub Desktop.
Pi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| template <typename T> | |
| inlinealways T pi( ) { | |
| const static long double p = 3.1415926535897932384626433832795028841971693; | |
| return static_cast<T>( p ); | |
| } | |
| template <typename T> | |
| inlinealways T two_pi( ) { | |
| return static_cast<T>( pi<long double>( ) * 2 ); | |
| } | |
| template <typename T> | |
| inlinealways T root_two_pi( ) { | |
| const static long double r2pi = 2.50662827463; | |
| return static_cast<T>( r2pi ); | |
| } | |
| template <typename T> | |
| inlinealways T root_pi( ) { | |
| const static long double rpi = 1.77245385091; | |
| return static_cast<T>( rpi ); | |
| } | |
| template <typename T> | |
| inlinealways T inverse_pi( ) { | |
| return static_cast<T>( 1 / pi<long double>( ) ); | |
| } | |
| template <typename T> | |
| inlinealways T inverse_two_pi( ) { | |
| return static_cast<T>( 1 / two_pi<long double>( ) ); | |
| } | |
| template <typename T> | |
| inlinealways T half_pi( ) { | |
| return static_cast<T>( pi<long double>( ) / 2 ); | |
| } | |
| template <typename T> | |
| inlinealways T quarter_pi( ) { | |
| return static_cast<T>( pi<long double>( ) / 4 ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment