From: Johan RÃ¥de (rade_at_[hidden])
Date: 2007-03-15 09:46:30
Stephan Tolksdorf wrote:
> Johan RÃ¥de wrote:
>> The floating_point_utilities library solves this problem.
>> See the documentation of the header nonfinite_num_facets.hpp.
>> The library also provides portable implementations of fpclassify, isnan,
>> signbit etc.
> Hi Johan,
> What do you think about using the platform signbit and copysign if
> available (in TR1, C99, MSVC, ...)? There is a chance that the compiler
> optimizes the builtins better than expressions only using arithmetic primitives.
My implementation does not use any floating point operations.
It only does logical bit operations on the binary representations of
floating the numbers.
I did some timing tests on VC++ 7.1.
There my code was faster than the native implementation,
in some cases much faster.
However, the native implementation might of course be faster on some
> I realize that testing the availability of copysign or
> copysign_ is probably difficult to do in the headers only, but for a
> subset of platforms it should be feasible.
One solution might be to let the user decide which implementation to
use. My implementation would be the default, but if the user defines the
macro BOOST_USE_NATIVE_FPCLASSIFY, then my code would call the native
Boost list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk