$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
From: Johan Råde (rade_at_[hidden])
Date: 2006-10-05 07:42:33
I have put together optimized implementations
of the following functions:
   template<class T> int fpclassify(T x);
   template<class T> bool isfinite(T x);
   template<class T> bool isinf(T x);
   template<class T> bool isnan(T x);
   template<class T> bool isnormal(T x);
   template<class T> bool signbit(T x);
   template<class T> T copysign(T x, T y);
   template<class T> T changesign(T x);
Here T is required to be float, double or long double.
--------------------
The code has been tested with
Windows / VC7.1 / i386
Mac / GCC 4.0 / powerpc
Linux / GCC 3.3 / i386, amd64, ia64, powerpc, mips, hppa
The code should work with most platforms
that support the IEEE754 standard.
--------------------
Many of these functions have also been
implemented by John Maddock.
The difference is that my implementation
is optimized for speed.
Here are some timing numbers on VC 7.1:
   float        Råde  Maddock  Native
   fpclassify     8      57       -
   isfinite       5      57       -
   isnormal       6      59       -
   isinf          5      57       -
   isnan          6      57       -
   double       Råde  Maddock  Native
   fpclassify    13      52      29
   isfinite      11      56      17
   isnormal      14      56       -
   isinf         10      52       -
   isnan          4      52      19
The times are in clock cycles for a single call,
based on an average of 10,000,000 calls
with random input.
--------------------
The code is available in the vault,
at "Home/Math - Numerics/fpclassify.zip".
Many thanks to Håkan Ardö who tested the code on Linux
and Olivier Verdie who tested the code on Mac.
--Johan Råde