[Rd] identical(0, -0)
Petr Savicky
savicky at cs.cas.cz
Wed Aug 12 13:50:46 CEST 2009
Let me add the following to the discussion of identical(0, -0).
I would like to suggest to replace the paragraph
'identical' sees 'NaN' as different from 'NA_real_', but all
'NaN's are equal (and all 'NA' of the same type are equal).
in ?identical by the following text, which is a correction of my previous
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 suggestion for the default of identical(0, -0) is TRUE, because the
negative zero is much less important than NA na NaN and, possibly,
distinguishing 0 and -0 could even be deprecated. Moreover, the argument
of efficiency of memcmp cannot be used here, since there are different
variants of NaN and NA, which should not be distinguished by default.
Petr.
More information about the R-devel
mailing list