stdcxx-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Farid Zaripov (JIRA)" <>
Subject [jira] Commented: (STDCXX-51) infinity, NaN formatted differently on different platforms
Date Tue, 27 May 2008 15:32:00 GMT


Farid Zaripov commented on STDCXX-51:


As a general rule, when a QNaN is used in one or more arithmetic floating-point instructions,
is allowed to propagate through a computation. An SNaN on the other hand causes a floatingpoint
invalid-operation exception to be signaled. SNaNs are typically used to trap or invoke an
exception handler. They must be inserted by software; that is, *the* *FPU* *never* *generates*
*an* *SNaN*
*as* *a* *result*.

The floating-point invalid-operation exception has a flag and a mask bit associated with it
in the
FPU status and control registers, respectively (see Section 7.7., "Floating-Point Exception
Handling"). The mask bit determines how the FPU handles an SNaN value. *If* *the* *floating-point*
*invalid-operation* *mask* *bit* *is* *set,* *the* *SNaN* *is* *converted* *to* *a* *QNaN*
*by* *setting* *the* *most-significant*
*fraction* *bit* *of* *the* *value* *to* *1.* The result is then stored in the destination
operand and the
floating-point invalid-operation flag is set. If the invalid-operation mask is clear, a floating-point
invalid-operation fault is signaled and no result is stored in the destination operand.

> infinity, NaN formatted differently on different platforms
> ----------------------------------------------------------
>                 Key: STDCXX-51
>                 URL:
>             Project: C++ Standard Library
>          Issue Type: Improvement
>          Components: 22. Localization
>    Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0, 4.2.1
>         Environment: all
>            Reporter: Martin Sebor
>            Assignee: Martin Sebor
>            Priority: Minor
>             Fix For: 4.2.2
>         Attachments: num_put.diff
>   Original Estimate: 13h
>          Time Spent: 13h
>  Remaining Estimate: 8h
> The output of the program below is different depending on the operating system it runs
on. It should be the same (preferably like that on AIX).
> {noformat}
> $ cat u.cpp && uname -sr && make u -r && ./u
> #include <iostream>
> #include <limits>
> int main ()
> {
>     std::cout << std::numeric_limits<double>::infinity () << '\n'
>               << std::numeric_limits<double>::quiet_NaN () << '\n'
>               << std::numeric_limits<double>::signaling_NaN () << '\n';

> }
> SunOS 5.9
> gcc -c -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG   -pthreads -D_RWSTD_USE_CONFIG
-I/build/sebor/gcc-3.4.3-15s/include -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/examples/include
 -pedantic -nostdinc++ -g  -Wall -W -Wcast-qual -Winline -Wshadow -Wwrite-strings -Wno-long-long
> gcc u.o -o u -pthreads -L/build/sebor/gcc-3.4.3-15s/lib -lstd15s  -lsupc++ -lm
> rm u.o
> inf
> nan
> nan
> $ uname -vs && gmake u -r && ./u
> AIX 5
> xlCcore_r -c -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG    -D_RWSTD_USE_CONFIG
-I/build/sebor/vacpp- -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/examples/include
 -g  -q64  -qtemplateregistry=u.ti   u.cpp
> xlCcore_r u.o -o u -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG    -D_RWSTD_USE_CONFIG
-liconv -brtl   -q64 -I/build/sebor/dev/stdlib/include/ansi -D_RWSTDDEBUG    -D_RWSTD_USE_CONFIG
-I/build/sebor/vacpp- -I/build/sebor/dev/stdlib/include -I/build/sebor/dev/stdlib/examples/include
 -qtemplateregistry=u.ti -L/build/sebor/vacpp- -lstd15D   -lm
> rm u.o
> inf
> nanq
> nans
> {noformat}

This message is automatically generated by JIRA.
You can reply to this email to add a comment to the issue online.

View raw message