[vtk-developers] unsigned/signed comparison

Bill Lorensen bill.lorensen at gmail.com
Wed Dec 23 17:49:57 EST 2009


I agree with Andrew. Avoid the casts if possible.

On Wed, Dec 23, 2009 at 4:57 PM, Andrew Maclean
<andrew.amaclean at gmail.com> wrote:
> If polygon2->GetNumberOfPoints() is returning int the you should use:
> for (int i ...
>
> Regards
>   Andrew
>
>
> On Thu, Dec 24, 2009 at 8:49 AM, David Doria <daviddoria+vtk at gmail.com> wrote:
>> Is the preferred way to do this comparison:
>> for(unsigned int i = 0; i < polygon2->GetNumberOfPoints(); i++)
>>
>> to use a signed int for the counter:
>> for(int i = 0; i < polygon2->GetNumberOfPoints(); i++)
>>
>> or cast the compare value as an unsigned int:
>> for(unsigned int i = 0; i < static_cast<unsigned
>> int>(polygon2->GetNumberOfPoints()); i++)
>>
>> Thanks,
>>
>> David
>> _______________________________________________
>> 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
>>
>>
>
>
>
> --
> ___________________________________________
> Andrew J. P. Maclean
> Centre for Autonomous Systems
> The Rose Street Building J04
> The University of Sydney  2006  NSW
> AUSTRALIA
> Ph: +61 2 9351 3283
> Fax: +61 2 9351 7474
> URL: http://www.acfr.usyd.edu.au/
> ___________________________________________
> _______________________________________________
> 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