The R Project SVN R

Rev

Rev 84815 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 84815 Rev 89319
Line 11... Line 11...
11
# And because most libm pow() functions special-case integer powers.
11
# And because most libm pow() functions special-case integer powers.
12
10^-(324:307-0.01)/10^0.01
12
10^-(324:307-0.01)/10^0.01
13
 
13
 
14
# IEC60559 mandates this, but C99/C11 do not.
14
# IEC60559 mandates this, but C99/C11 do not.
15
# Mingw-w64 did not do so in v 2.0.1
15
# Mingw-w64 did not do so in v 2.0.1
16
x <- 0*(-1) # negative zero
16
(x <- 0*(-1)) # negative zero (prints as '0' in R on purpose!)
17
sqrt(x)
17
rt_0 <- sqrt(x) # ditto  -- but sprintf() shows "-0" :
18
sprintf("%g, rt = %g, .^2 = %g", x, sqrt(x), x^2)
18
sprintf("%g, rt = %g, .^2 = %g", x, sqrt(x), x^2)
-
 
19
stopifnot(exprs = {
19
identical(x, sqrt(x))
20
    identical(1/ x, -Inf)
-
 
21
    identical(1/-x, +Inf)
-
 
22
    identical(x, -x,) # default num.eq=TRUE  ==> -0 "identical" 0
-
 
23
    ! identical(x, -x,    num.eq=FALSE) # but not bitwise identical
-
 
24
    identical(x, sqrt(x), num.eq=FALSE) # sqrt(-0) == -0
-
 
25
    identical(-x, x^2,    num.eq=FALSE) # (-0)^2   == +0 = --0
-
 
26
})