From hp@ge@@on@g|thub @end|ng |rom gm@||@com  Fri Sep 10 17:48:01 2021
From: hp@ge@@on@g|thub @end|ng |rom gm@||@com (=?UTF-8?B?SGVydsOpIFBhZ8Oocw==?=)
Date: Fri, 10 Sep 2021 08:48:01 -0700
Subject: [Rd] Unneeded if statements in RealFromComplex C code
In-Reply-To: <24891.9273.43964.300205@stat.math.ethz.ch>
References: <af8f0c90-b643-3151-82ba-4e3efccb1e1f@gmail.com>
 <24891.9273.43964.300205@stat.math.ethz.ch>
Message-ID: <08c59f31-555f-5ea0-cac2-868251f6990d@gmail.com>

Thanks Martin!

Best,
H.

On 10/09/2021 02:24, Martin Maechler wrote:
>>>>>> Herv? Pag?s
>>>>>>      on Thu, 9 Sep 2021 17:54:06 -0700 writes:
> 
>      > Hi,
> 
>      > I just stumbled across these 2 lines in RealFromComplex (lines 208 & 209
>      > in src/main/coerce.c):
> 
>      > double attribute_hidden
>      > RealFromComplex(Rcomplex x, int *warn)
>      > {
>      >   if (ISNAN(x.r) || ISNAN(x.i))
>      >       return NA_REAL;
>      >   if (ISNAN(x.r)) return x.r;        <- line 208
>      >   if (ISNAN(x.i)) return NA_REAL;    <- line 209
>      >   if (x.i != 0)
>      >      *warn |= WARN_IMAG;
>      >   return x.r;
>      > }
> 
>      > They were added in 2015 (revision 69410).
> 
> by me.  "Of course" the intent at the time was to  *replace* the
> previous 2 lines and return NA/NaN of the "exact same kind"....
> 
> but in the mean time, I have learned that trying to preserve
> exact *kinds* of NaN / NA is typically not platform portable,
> anyway because compiler/library optimizations and
> implementations are pretty "free to do what they want" with these.
> 
>      > They don't serve any purpose and might slow things down a little (unless
>      > compiler optimization is able to ignore them). In any case they should
>      > probably be removed.
> 
> I've cleaned up now, indeed back compatibly, i.e., removing both
> lines as you suggested.
> 
> Thank you, Herv?!
> 
> Martin
> 
> 
>      > Cheers,
>      > H.
> 
>      > --
>      > Herv? Pag?s
> 
>      > Bioconductor Core Team
>      > hpages.on.github at gmail.com
> 

-- 
Herv? Pag?s

Bioconductor Core Team
hpages.on.github at gmail.com



[Rd] Unneeded if statements in RealFromComplex C code
=?UTF-8?B?SGVydsOpIFBhZ8Oocw==?=