Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2001-11-07 07:35:14


From: "Mark Rodgers" <mark.rodgers_at_[hidden]>
> From: "Ed Brey" <edbrey_at_[hidden]>
> > To make sure that we're on the same wavelength, I'm thinking of:
> >
> > inline double sqrt(double x) { // boost version
> > if (x == 2) return 1.41;
> > if (x == 3) return 1.73;
> > return std::sqrt(x);
> > }
>
> How do you know that std::sqrt doesn't already do something similar?

You can't.

> I think we should leave such optimisations to the vendor, and not
> try and second guess what they might be doing. Adding our own
> "optimisation" on top of theirs might just make things worse.

Portability. boost::sqrt(2) would be _documented_ to return exactly
1.4142...

--
Peter Dimov
Multi Media Ltd.

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk