[vtk-developers] More on infinity and NaN in VTK

Philippe Pébay pppebay at sandia.gov
Mon May 23 17:59:26 EDT 2011


Hello,

Following the message which I posted last week (no response so far) regarding infinity and NaN in VTK, I looked a bit 
deeper into the issue and noticed the following apparent contradiction:

1. In vtkMathConfigure.in we have the following:

// We pretty much assume that all compilers are going to provide
// std::numeric_limits methods in the limits header.  On of the Borland
// dashboard compilers failed to link in the methods, so we have a special
// case here.  If we find more platforms that do not support it correctly,
// then we should probably implement a TRY_COMPILE in the CMakeLists.txt.
#ifndef __BORLANDC__
# define VTK_HAS_STD_NUMERIC_LIMITS
#endif

which means that for all platforms save Borland, we will assume that numeric_limits are present.

2. However, in vtkMath.cxx we have for Nan() (and something similar for Inf()):

double vtkMath::Nan()
{
#if defined(VTK_HAS_STD_NUMERIC_LIMITS)
   return vtkstd::numeric_limits<double>::quiet_NaN();
#elif defined(__BORLANDC__)
   return *reinterpret_cast<double*>(&vtkMathNanBits);
#else
   return vtkMathNanBits.d;
#endif
}

with the effect that the first if statement is rendered useless by the definitions in vtkMathConfigure.

Is this done on purpose? Am I missing something else in the picture?

Thanks
Philippe


On 05/23/2011 02:18 PM, Brad King wrote:
> On Mon, May 23, 2011 at 4:13 PM, Philippe Pébay<pppebay at sandia.gov>  wrote:
>> If you have a few minutes, I would like to discuss the issue of infinity and NaN in VTK.
>
> The most I've ever done with that type of thing is investigate the
> portability of isnan and isinf tests, but that was probably 5 years
> ago.  Hopefully someone will respond on the vtk or titan lists.
> Otherwise I suggest proposing a more specific plan.
>
> -Brad
>


-- 
Philippe Pébay
Sandia National Laboratories





More information about the vtk-developers mailing list