[Insight-developers] NumericTraits for long long and __int64

Bradley Lowekamp blowekamp at mail.nih.gov
Mon Nov 23 11:21:29 EST 2009


On Nov 23, 2009, at 10:57 AM, Tom Vercauteren wrote:

> Hi Brad,
> 
> I am not sure I can really help you on that particular problem. Just a
> comment and a question below:
> 
> 1) borland c++ 5.5 compiler is now freeware:
>  http://edn.embarcadero.com/article/20633
> I have successfully used it on wndows XP. It makes borland debugging
> much easier than when relying solely on the dashboard feedback...

That is good to know for the future.

> 
> 
> 2) What's the rationale behind using __int64? Isn't it a microsoft
> specific type? Why not simply use int64_t which is already available
> on many compiler and can be provided on even more of them by including
> pstdint.h (or cstdint.hpp from boost)?
> http://www.azillionmonkeys.com/qed/pstdint.h
> 

I believe that using the cstdint types is very good for higher levels, when specific sized integers are needed. And there are also the fixed width integers and reals defined in vxl. So there are options to choose from. And I believe we are making progress to adopting one of these, through support in the NumericTraits.

However, the NumericTraits need to be defined in terms of the fundamental types. So the above typedef would not work well. If we did define them all in terms of cstdints we would have a problem of not all fundamental types being defined. For example on 32-bit systems many time int and long are both 32-bits, yet we would only have a NumericTraits for one of these. The other would not be specialized and problems would follow. Hence we must define the numeric traits as fundamental types, and not cstdnt, size_t, ptrdiff_t etc...

Brad

> 
> Tom
> 
> On Mon, Nov 23, 2009 at 16:14, Bradley Lowekamp <blowekamp at mail.nih.gov> wrote:
>> Hello,
>> I have been working on adding NumericTraits for types long long and __int64.
>> To address the issue of size_t being type long long on win64, and to get a
>> more portable 64-bit integer.
>> The traits for type long long and unsigned long long seem to be working on
>> the systems which support the tyoe. std::numeric_limits is specialized and
>> the values seem to be set and printed ok in the NumericTraitsTest.
>> Unfortunately __int64 does not seem to be working right. It appears that the
>> Borland compiler is the only one where it is a fundamental type and it is
>> convertible to double. It does not have a specialized std::numeric_limits
>> defined. More problematic is the basic value of One and Zero set it
>> itkNumericTraits.cxx don't seem to be functioning correctly. The output of
>> itkNumericTraitsTest is:
>> 
>> itk::NumericTraits<__int64>
>> is_specialized: 0
>> digits: 0
>> digits10: 0
>> 
>> 	is_signed: 0
>> 	round_error(): 0
>> 	denorm_min(): 0
>> 	epsilon(): 0
>> 	min(): 0
>> 	max(): 0
>> 	IsPositive( One )0
>> 	IsNonpositive( One )1
>> 	IsNegative( One )1
>> 	IsNonnegative( One )0
>> 	Zero: 1072693248
>> 	One: 0
>> 	ZeroValue(): 1072693248
>> 	OneValue(): 0
>> 	max(__int64): 0
>> 	min(__int64): 0
>> 	NonpositiveMin(): 0
>> itk::NumericTraits<unsigned __int64>
>> 	is_specialized: 0
>> 	digits: 0
>> 	digits10: 0
>> 	is_signed: 0
>> 	round_error(): 0
>> 	denorm_min(): 0
>> 	epsilon(): 0
>> 	min(): 0
>> 	max(): 0
>> 	IsPositive( One )1
>> 	IsNonpositive( One )0
>> 	IsNegative( One )0
>> 	IsNonnegative( One )1
>> 	Zero: 0
>> 	One: 1
>> 	ZeroValue(): 0
>> 	OneValue(): 1
>> 	max(unsigned __int64): 0
>> 	min(unsigned __int64): 0
>> 	NonpositiveMin(): 0
>> 
>> Take note of the One and Zero values it "__int64".
>> I don't have access to the borland compiler, and don't know how to look into
>> this issue further. I am tempted to say that we just shouldn't support the
>> __int64 type as it'll make things simpler.
>> Brad
>> 
>> ========================================================
>> 
>> Bradley Lowekamp
>> 
>> Lockheed Martin Contractor for
>> 
>> Office of High Performance Computing and Communications
>> 
>> National Library of Medicine
>> 
>> blowekamp at mail.nih.gov
>> 
>> 
>> _______________________________________________
>> Powered by www.kitware.com
>> 
>> Visit other Kitware open-source projects at
>> http://www.kitware.com/opensource/opensource.html
>> 
>> Kitware offers ITK Training Courses, for more information visit:
>> http://kitware.com/products/protraining.html
>> 
>> Please keep messages on-topic and check the ITK FAQ at:
>> http://www.itk.org/Wiki/ITK_FAQ
>> 
>> Follow this link to subscribe/unsubscribe:
>> http://www.itk.org/mailman/listinfo/insight-developers
>> 
>> 

========================================================
Bradley Lowekamp  
Lockheed Martin Contractor for
Office of High Performance Computing and Communications
National Library of Medicine 
blowekamp at mail.nih.gov


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.itk.org/mailman/private/insight-developers/attachments/20091123/f40bac71/attachment.htm>


More information about the Insight-developers mailing list