[Numpy-discussion] Off-Topic 754 question (was RE: Possible bug (was Re: numpy, overflow, inf, ieee, and rich comparison)
Jonathan M. Gilligan
jonathan.gilligan at vanderbilt.edu
Thu Oct 12 16:47:40 CDT 2000
This is a bit off-topic, but I noticed that there are lots of experts here
and I have a question about IEEE-754 that has been bugging me for some time
and which I was not able to get a good answer for on the USENET newsgroups.
I am hoping that one of the experts in this list will take pity on my
ignorance and answer what should be a simple question.
Under Microsoft Visual C++, the Standard C++ library's
numeric_limits<float>::signaling_NaN() and
numeric_limits<double>::signaling_NaN() both return -INF values. The
numeric_limits<float>::quiet_NaN() and numeric_limits<double>::quiet_NaN()
both return -IND.
I have not been able to determine whether this is "proper" behavior or
whether it is another example of Microsoft ignoring standards? I would have
thought that one of the two should return NaN. I certainly can't for the
life of me figure out why someone would call INF a NaN, but as I have said,
I'm pretty ignorant.
Right now, if I want to use NaN's in my C++ code (e.g., to initialize newly
allocated memory blocks) I build NaNs thus:
>static long iNAN[2] =
>{
> 0xFFFFFFFF, 0xFFFFFFFF
>};
>
>static double dNAN(
> *reinterpret_cast<double *>(iNaN))
but would prefer something a little less bit-tweaky.
Microsoft's documentation that this is the way they intend their library to
work may be found at:
http://msdn.microsoft.com/library/devprods/vs6/visualc/vclang/sample_Members_of_the_numeric_limits_Class_(STL_Sample).htm#_sample_stl_numeric_limits_class
Thanks,
Jonathan
=============================================================================
Jonathan M. Gilligan jonathan.gilligan at vanderbilt.edu
The Robert T. Lagemann Assistant Professor Office: 615 343-6252
of Living State Physics Lab (FEL) 343-7580
Dept. of Physics and Astronomy, Box 1807-B Fax: 343-7263
6823 Stevenson Center
Vanderbilt University, Nashville, TN 37235 Dep't Office: 322-2828
More information about the Numpy-discussion
mailing list