Issue Details (XML | Word | Printable)

Key: STDCXX-819
Type: Bug Bug
Status: Open Open
Priority: Minor Minor
Assignee: Martin Sebor
Reporter: Farid Zaripov
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
C++ Standard Library

[MSVC] numeric_limits::quiet_NaN() and signaling_NaN() bits differ from native STL

Created: 01/Apr/08 06:06 PM   Updated: 29/May/08 09:23 PM
Return to search
Component/s: 18. Language Support
Affects Version/s: 4.1.2, 4.1.3, 4.1.4, 4.2.0, 4.2.1
Fix Version/s: 4.2.2

Time Tracking:
Original Estimate: 4h
Original Estimate - 4h
Remaining Estimate: 4h
Remaining Estimate - 4h
Time Spent: Not Specified
Remaining Estimate - 4h

Environment: MSVC and ICC/Windows
Issue Links:
Reference
 

Severity: Incorrect Behavior


 Description  « Hide
The binary representation of NAN's in stdcxx:
#define _RWSTD_FLT_QNAN_BITS  { 0, 0, '\xc0', '\xff' }
#define _RWSTD_FLT_SNAN_BITS  { '\x1', 0, '\x80', '\x7f' }
#define _RWSTD_DBL_QNAN_BITS  { 0, 0, 0, 0, 0, 0, '\xf8', '\xff' }
#define _RWSTD_DBL_SNAN_BITS  { '\x1', 0, 0, 0, 0, 0, '\xf0', '\x7f' }
#define _RWSTD_LDBL_QNAN_BITS  { 0, 0, 0, 0, 0, 0, '\xf8', '\xff' }
#define _RWSTD_LDBL_SNAN_BITS  { '\x1', 0, 0, 0, 0, 0, '\xf0', '\x7f' }

The binary representation of the same things in MSVC STL:

#define _RWSTD_FLT_QNAN_BITS  { 0, 0, '\xc0', '\x7f' }
#define _RWSTD_FLT_SNAN_BITS  { '\x1', 0, '\xc0', '\x7f' }
#define _RWSTD_DBL_QNAN_BITS  { 0, 0, 0, 0, 0, 0, '\xf8', '\x7f' }
#define _RWSTD_DBL_SNAN_BITS  { '\x1', 0, 0, 0, 0, 0, '\xf8', '\x7f' }
#define _RWSTD_LDBL_QNAN_BITS  { 0, 0, 0, 0, 0, 0, '\xf8', '\x7f' }
#define _RWSTD_LDBL_SNAN_BITS  { '\x1', 0, 0, 0, 0, 0, '\xf8', '\x7f' }


 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Farid Zaripov added a comment - 01/Apr/08 06:10 PM - edited
As a result the following program outputs the defferent results:
#include <float.h>
#include <iostream>
#include <limits>

int main ()
{
    std::cout << _copysign (1., std::numeric_limits<double>::quiet_NaN ()) << '\n';
    std::cout << _copysign (1., -std::numeric_limits<double>::quiet_NaN ()) << '\n';
    std::cout << _copysign (1., std::numeric_limits<double>::signaling_NaN ()) << '\n';
    std::cout << _copysign (1., -std::numeric_limits<double>::signaling_NaN ()) << '\n';

    return 0;
}

The result in MSVC STL:

1
-1
1
-1

The result in stdcxx:

-1
-1
1
1

Martin Sebor added a comment - 02/Apr/08 03:01 PM
Replaced [_MSC_VER] tag with [MSVC] in Summary for consistency with other MSVC issues and abbreviated the rest of the text to make it more easily readable in reports.

Martin Sebor added a comment - 02/Apr/08 03:11 PM
The bit patterns for Infinities and NaNs are automatically detected in the INFINITY.cpp config test. There are many possible representations of both classes of numbers so if we want to be completely consistent with the native STL (or with the C library on each platform) we'll need to hardcode the exact patterns into the config test. Before we do that, it would be good to do a survey of existing platforms and document the native bit patterns in a single place (e.g., in this issue or, perhaps even better, on the Wiki).

Farid Zaripov added a comment - 02/Apr/08 03:19 PM
I've tested the test sample above with native STL on 64-bit MSVC, and this sample has failed. The output was:
1
1
1
1

So now I think that this issue should be closed as Won't Fix.


Martin Sebor added a comment - 02/Apr/08 03:24 PM
See also the tangentially related STDCXX-740.

Martin Sebor added a comment - 02/Apr/08 03:28 PM
Corrected Component/s: numeric_limits is in the Language Support library.

Martin Sebor added a comment - 02/Apr/08 03:32 PM
See also STDCXX-797 for a similar issue on HP-UX.

Farid Zaripov added a comment - 09/Apr/08 03:10 PM
Lowered priority since now we don't using the sign of nan values in formatting (see STDCXX-51) and deferred to the later release.

Martin Sebor added a comment - 29/May/08 09:23 PM
Rescheduled for 4.2.2.

Martin Sebor added a comment - 29/May/08 09:23 PM
Added 4.2.1 to affected versions.