On Wed, 18 Jun 2003 15:15:24 +0100, "Paul A Bristow" <[EMAIL PROTECTED]> wrote:
[...] >Maximum possible accuracy is a central feature, >promising the best possible portability, >especially for intervals where every really bit really counts. > >It was also agree that any casting to obtain other types did not >garanteed accuracy and this was why the proposed code uses namespaces >to allow selection of the FP size either individually: In Daniel's solution static_cast<type>(x) simply "selects" the corresponding specialization of x_value. So static_cast<float>(pi) is fundamentally different from, say, double pi = ...; static_cast<float>(pi) [...] > >Although your operators are neat, speeding -sin(pi/two), >my suspicion is that it is better to pre-calculate as many >constants as possible, and as accurately as possible. >I don't think this counts as "premature optimisation" :-) In fact it's not a matter of speed, but of precision. I'm sure there are compilers where the -sin(pi/2.) in the example code is faster than -sin(pi/two ). However an overload allows you to specify that the value of, say, arccos(-1) [math::acos(minus_one)] is exactly pi. Genny. _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost