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

Moreland, Kenneth kmorel at sandia.gov
Mon May 23 18:14:31 EDT 2011


This looks like defensive programming to me.  It's dangerous to assume
that VTK_HAS_STD_NUMERIC_LIMITS == !__BORLANDC__.  It could also be that
the implementation for neither case was for some other older compiler that
is no longer supported.  In either case, I would leave the code how it is.
 You could replace the "return vtkMathNanBits.d" with something like
"#error Can't figure out NaN for current compiler", but I would definitely
leave the third condition there.

-Ken

   ****      Kenneth Moreland
    ***      Sandia National Laboratories
***********  
*** *** ***  email: kmorel at sandia.gov
**  ***  **  phone: (505) 844-8919
    ***      web:   http://www.cs.unm.edu/~kmorel




On 5/23/11 5:59 PM, "Philippe Pébay" <pppebay at sandia.gov> wrote:

>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
>
>
>_______________________________________________
>Powered by www.kitware.com
>
>Visit other Kitware open-source projects at
>http://www.kitware.com/opensource/opensource.html
>
>Follow this link to subscribe/unsubscribe:
>http://www.vtk.org/mailman/listinfo/vtk-developers
>
>





More information about the vtk-developers mailing list