Re: [HACKERS] NAN code - Mailing list pgsql-hackers

From orion.SAPserv.Hamburg.dsh.de!wieck@sapserv.debis.de
Subject Re: [HACKERS] NAN code
Date
Msg-id m0zxBIM-000EBPC@orion.SAPserv.Hamburg.dsh.de
Whole thread Raw
In response to NAN code  (Bruce Momjian <maillist@candle.pha.pa.us>)
List pgsql-hackers
>
> I have changed the NAN code, so if NAN is not defined, we just use 'num'
> as NAN, since we only get here if num is NAN.  Seems like a good fix for
> platforms that can't assign a NAN to a variable.
>
> ---------------------------------------------------------------------------
>
>     if (NUMERIC_IS_NAN(num))
>     {
>         result = (float32)palloc(sizeof(float32data));
> #ifdef NAN
>         *result = NAN;
> #else
>         *result = num;
> #endif
>         return result;
>     }

    And  I  where  so happy to have finally found that damned NAN
    define :-}

    Anyway - that above is absolutely wrong.

    num is  of  type  Numeric,  which  is  a  pointer  to  struct
    NumericData!   So  the  above  should result in some compiler
    warning (in fact it type casts a pointer into a double  value
    - and that will give unpredictable results).

    Seems  that only isnan() is defined as part of Posix. But not
    a definition that can force a NAN.  So  we  have  to  find  a
    portable  way  to  define the value NaN for double and float.
    Does anybody know of such a way?


Jan

--

#======================================================================#
# It's easier to get forgiveness for being wrong than for being right. #
# Let's break this rule - forgive me.                                  #
#======================================== jwieck@debis.com (Jan Wieck) #

pgsql-hackers by date:

Previous
From: The Hermit Hacker
Date:
Subject: Re: [HACKERS] a test
Next
From: orion.SAPserv.Hamburg.dsh.de!wieck@sapserv.debis.de
Date:
Subject: Re: [HACKERS] Error creating index