[Rd] identical(0, -0)
Martin Maechler
maechler at stat.math.ethz.ch
Wed Aug 12 16:02:28 CEST 2009
>>>>> "PS" == Petr Savicky <savicky at cs.cas.cz>
>>>>> on Wed, 12 Aug 2009 13:50:46 +0200 writes:
PS> Let me add the following to the discussion of identical(0, -0).
PS> I would like to suggest to replace the paragraph
PS> 'identical' sees 'NaN' as different from 'NA_real_', but all
PS> 'NaN's are equal (and all 'NA' of the same type are equal).
PS> in ?identical by the following text, which is a correction of my previous
PS> suggestion for the same paragraph
> Components of numerical objects are compared as follows. For non-missing
> values, "==" is used. In particular, '0' and '-0' are considered equal.
> All 'NA's of the same type are equal and all 'NaN's are equal, although
> their bit patterns may differ in some cases. 'NA' and 'NaN' are always
> different.
> Note also that 1/0 and 1/(-0) are different.
the 'numerical' would have to be qualified ('double', 'complex'
via double), as indeed, memcmp() is used on integers
The last sentence is not necessary and probably even confusing:
Of course, -Inf and Inf are different.
PS> The suggestion for the default of identical(0, -0) is TRUE, because the
PS> negative zero is much less important than NA na NaN and, possibly,
PS> distinguishing 0 and -0 could even be deprecated.
What should that mean?? R *is* using the international floating
point standards, and 0 and -0 exist there and they *are*
different!
If R would start --- with a performance penalty, btw ! ---
to explicitly map all internal '-0' into '+0' we would
explicitly move away from the international FP standards...
no way!
PS> Moreover, the argument
PS> of efficiency of memcmp cannot be used here, since there are different
PS> variants of NaN and NA, which should not be distinguished by default.
your argument is only partly true... as memcmp() can still be
used instead of '==' *after* the NA-treatments {my current
patch does so},
and even more as I have been proposing an option "strict" which
would only use memcmp() {and hence also distinguish different
NA, NaN's}.
Martin
More information about the R-devel
mailing list