
John Maddock wrote:
template <class T> T pi();
I have a fixed-point class. What actually happens when I call pi<fixed>() ? Presumably the implementation just does "return 3.1415...", so fixed::fixed(double) gets called. Yes my fixed class has a constructor that takes a double, and if I'm really lucky it may do the conversion at compile time - but more likely it will happen at run time. I would get the same code if you just declared "const double pi = 3.1415" (or #defined it). My 64-bit fixed point type can store more digits of PI than a 64-bit floating point value. But I'm not aware of any way of filling those extra digits [ignoring the existence of long double]. Similarly if I had an arbitrary precision (i.e. variable length) type, how would it be constructed from the 100-digit constants that you mention without support from the language (or maybe macros)? (As for the actual constants, the only ones I find myself using are pi and the approximate radius of the earth.) Cheers, Phil.