[Insight-developers] itk::Math:: limitations (was: Using Math::Floor in interpolation code?)

Tom Vercauteren tom.vercauteren at m4x.org
Mon Jul 20 12:29:40 EDT 2009


Hi Brad,


On Mon, Jul 20, 2009 at 17:40, Bradley Lowekamp<blowekamp at mail.nih.gov> wrote:
>
> On Jul 20, 2009, at 10:13 AM, Tom Vercauteren wrote:
>
> P.S.: As for the other itk::Math:: routines, the limitations are that
> itk::Math::Floor is only guaranteed to work for arguments less than
> INT_MAX/2. Also it expects the FPU rounding mode to be the default
> one.
> <itk-InterpolateFloor-2009-07-20.patch><ATT00001.txt>
>
> Is it limited to INT_MAX/2 for 64-bit integers too?

I am not sure what you mean by "for 64-bit integers" since the
itk::Math:: routines take a float or double as input and produce an
int as output and, as far as I know, int is usually 32 bits even on 64
bit platforms.

That being said, it is true that the INT_MAX/2 limitation also holds
on 64 bits systems. Actually, for almost all itk::Math:: routines, one
should currently assume that they only work for arguments that have an
absolute value less than INT_MAX/2-1 *. The main exception being
RoundHalfIntegerToEven that works up to INT_MAX.

When I initially started working on those rounding functions for ITK,
the discussions on the list led to a consensus that these limitations
were not a problem. Do you think otherwise? Would you be in favor for
adding an assert in these rounding functions for this INT_MAX/2
limitation so that errors might be caught in a debug mode?

Tom


* The actual implementation of the itk::Math:: routines depend on the
architecture and compiler so in some cases, it might work but I
definitely wouldn't rely on that.


More information about the Insight-developers mailing list