here is some example code that shows what ksh93/ast use for printing nan
on systems that support both isnan() and signbit()
---
#include <stdio.h>
#include <math.h>
int
main()
{
        long double     v;
        long double     z = 0.0;

        v = z / z;
        printf("isnan=%d signbit=%d %Lg\n", !!isnan(v), !!signbit(v), v);
        v = -v;
        printf("isnan=%d signbit=%d %Lg\n", !!isnan(v), !!signbit(v), v);
        return 0;
}
---
from a few tests it seems that it may be an x86 issue
for the ast stdio
on non-x86 systems
        isnan=1 signbit=0 nan
        isnan=1 signbit=1 -nan
and on x86 systems (linux solaris)
        isnan=1 signbit=1 -nan
        isnan=1 signbit=0 nan

On Sat, 3 Apr 2010 17:17:26 +0200 =?KOI8-R?B?z8zYx8Egy9LZ1sHOz9fTy8HR?= wrote:
> #include <stdio.h>
> #include <stdlib.h>
> #include <math.h>

> int main()
> {
>       long double a;
>       long double b;
>       
>       a=0.L;
>       b=0.L;
>       
>       printf ("%Lf\n", a/b);
>       return 0;
> }

> prints

> -NaN on i386 and NaN on SPARC. I believe this is a compiler bug in Sun
> Studio cc.

> Olga

> On Sat, Apr 3, 2010 at 3:58 PM, Chris Pickett
> <[email protected]> wrote:
> > We've been debugging a weired problem on Solaris/Intel this week. It
> > turns out that print -- $(( 0./0. )) returns nan on SPARC but -nan on
> > Intel. Is this a bug or a difference in the underlying floating point
> > data type representation?
> >
> > Chris
> > --
> >    ^---^
> >   (@)v(@)  Chris Pickett
> >   |    /   IT consultant
> >  ===m==m=== [email protected]
> > _______________________________________________
> > ksh93-integration-discuss mailing list
> > [email protected]
> > http://mail.opensolaris.org/mailman/listinfo/ksh93-integration-discuss
> >

> -- 
>       ,   _                                    _   ,
>      { \/`o;====-    Olga Kryzhanovska   -====;o`\/ }
> .----'-/`-/     [email protected]   \-`\-'----.
>  `'-..-| /     Solaris/BSD//C/C++ programmer   \ |-..-'`
>       /\/\                                     /\/\
>       `--`                                      `--`
> _______________________________________________
> ksh93-integration-discuss mailing list
> [email protected]
> http://mail.opensolaris.org/mailman/listinfo/ksh93-integration-discuss

_______________________________________________
tools-compilers mailing list
[email protected]

Reply via email to