[vtk-developers] vtkMath::Ceil() and vtkMath::Floor()

David Gobbi david.gobbi at gmail.com
Thu Jun 2 17:20:55 EDT 2011


Hi Philippe,

I wrote the Floor() and Ceil() functions a few months ago.  They are
written specifically for speed.  For double values that are within the
int range, they give exact results.

The vtkMath::Round() is fast, too, but the operation that it performs
does not conform to any of the IEEE 754 standard rounding modes.

 - David

On Thu, Jun 2, 2011 at 3:09 PM, Philippe Pébay <pppebay at sandia.gov> wrote:
> ... a clarification of what I asked earlier...
>
> By "different intent" I was referring to the fact that vtkMath's Floor() and
> Ceil() perform something which I find a little intriguing, namely, casting a
> double to an int, and then re-casting the latter to a double to perform a
> double-double equality comparison, which, I would venture to say, should be
> avoided whenever possible.
>
> On the other hand, Round() does not do this double casting but directly
> performs double-double inequality comparison, and a single cast to an int at
> the end. This seems much better to me.
>
> Thanks
> Philippe
>
> On 06/02/2011 02:04 PM, Philippe Pébay wrote:
>>
>> Hello,
>>
>> I was contemplating using vtkMath::Ceil() and vtkMath::Floor() in some
>> of my code, instead of the standard ceil() and floor(). However they
>> appear to be written with a slightly different intent than
>> vtkMath::Round(). Can someone comment on that?
>>
>> Thanks
>> Philippe
>
>
> --
> 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