Skip to content

Instantly share code, notes, and snippets.

@milesrout
Created June 23, 2014 05:39
Show Gist options
  • Save milesrout/a45a8a15901082991501 to your computer and use it in GitHub Desktop.
Save milesrout/a45a8a15901082991501 to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
template <typename T, typename = typename std::enable_if<std::is_floating_point<T>::value, void>::type>
constexpr T pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798;
int main()
{
float radiusf;
cin >> radiusf;
float areaf = pi<float> * radiusf * radiusf;
double radius;
cin >> radius;
double area = pi<double> * radius * radius;
cout << radiusf << endl;
cout << radius << endl;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment