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

From jwieck@debis.com (Jan Wieck)
Subject Re: [HACKERS] NAN code
Date
Msg-id m0zx5GY-000EBPC@orion.SAPserv.Hamburg.dsh.de
Whole thread Raw
In response to NAN code  (Bruce Momjian <maillist@candle.pha.pa.us>)
Responses Re: [HACKERS] NAN code
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: jwieck@debis.com (Jan Wieck)
Date:
Subject: Re: [HACKERS] Error creating index
Next
From: jwieck@debis.com (Jan Wieck)
Date:
Subject: Re: [HACKERS] snapshot and FreeBSD-2.2.7 not building