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 1... Line 1...
1
 
1
 
2
R Under development (unstable) (2022-03-19 r81942) -- "Unsuffered Consequences"
2
R Under development (unstable) (2026-01-21 r89314) -- "Unsuffered Consequences"
3
Copyright (C) 2022 The R Foundation for Statistical Computing
3
Copyright (C) 2026 The R Foundation for Statistical Computing
4
Platform: x86_64-pc-linux-gnu (64-bit)
4
Platform: x86_64-pc-linux-gnu
5
 
5
 
6
R is free software and comes with ABSOLUTELY NO WARRANTY.
6
R is free software and comes with ABSOLUTELY NO WARRANTY.
7
You are welcome to redistribute it under certain conditions.
7
You are welcome to redistribute it under certain conditions.
8
Type 'license()' or 'licence()' for distribution details.
8
Type 'license()' or 'licence()' for distribution details.
9
 
9
 
Line 50... Line 50...
50
[11] 1.000000e-314 1.000000e-313 1.000000e-312 1.000000e-311 1.000000e-310
50
[11] 1.000000e-314 1.000000e-313 1.000000e-312 1.000000e-311 1.000000e-310
51
[16] 1.000000e-309 1.000000e-308 1.000000e-307
51
[16] 1.000000e-309 1.000000e-308 1.000000e-307
52
> 
52
> 
53
> # IEC60559 mandates this, but C99/C11 do not.
53
> # IEC60559 mandates this, but C99/C11 do not.
54
> # Mingw-w64 did not do so in v 2.0.1
54
> # Mingw-w64 did not do so in v 2.0.1
55
> x <- 0*(-1) # negative zero
55
> (x <- 0*(-1)) # negative zero (prints as '0' in R on purpose!)
56
> sqrt(x)
-
 
57
[1] 0
56
[1] 0
-
 
57
> rt_0 <- sqrt(x) # ditto  -- but sprintf() shows "-0" :
58
> sprintf("%g, rt = %g, .^2 = %g", x, sqrt(x), x^2)
58
> sprintf("%g, rt = %g, .^2 = %g", x, sqrt(x), x^2)
59
[1] "-0, rt = -0, .^2 = 0"
59
[1] "-0, rt = -0, .^2 = 0"
-
 
60
> stopifnot(exprs = {
60
> identical(x, sqrt(x))
61
+    identical(1/ x, -Inf)
-
 
62
+    identical(1/-x, +Inf)
-
 
63
+    identical(x, -x,) # default num.eq=TRUE  ==> -0 "identical" 0
-
 
64
+    ! identical(x, -x,    num.eq=FALSE) # but not bitwise identical
-
 
65
+    identical(x, sqrt(x), num.eq=FALSE) # sqrt(-0) == -0
-
 
66
+    identical(-x, x^2,    num.eq=FALSE) # (-0)^2   == +0 = --0
61
[1] TRUE
67
+ })
62
> 
68
>