Skip to content

Commit

Permalink
add test for sqrt(-0)
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.r-project.org/R/trunk@58223 00db46b3-68df-0310-9c12-caf00c1e9a41
  • Loading branch information
ripley committed Jan 29, 2012
1 parent 028358d commit a56cb3d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions tests/iec60559.R
Expand Up @@ -10,3 +10,9 @@ exp(c(-745:-740, -730, -720, -710:-705))

# And because most libm pow() functions special-case integer powers.
10^-(324:307-0.01)/10^0.01

# IEC60559 mandates this, but C99/C11 do not.
# Mingw-w64 did not do so in v 2.0.1
x <- 0*(-1) # negative zero
sqrt(x)
identical(x, sqrt(x))
12 changes: 10 additions & 2 deletions tests/iec60559.Rout.save
@@ -1,8 +1,8 @@

R Under development (unstable) (2012-01-04 r58050)
R Under development (unstable) (2012-01-28 r58222)
Copyright (C) 2012 The R Foundation for Statistical Computing
ISBN 3-900051-07-0
Platform: i386-pc-mingw32/i386 (32-bit)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Expand Down Expand Up @@ -51,3 +51,11 @@ Type 'q()' to quit R.
[11] 1.000000e-314 1.000000e-313 1.000000e-312 1.000000e-311 1.000000e-310
[16] 1.000000e-309 1.000000e-308 1.000000e-307
>
> # IEC60559 mandates this, but C99/C11 do not.
> # Mingw-w64 did not do so in v 2.0.1
> x <- 0*(-1) # negative zero
> sqrt(x)
[1] 0
> identical(x, sqrt(x))
[1] TRUE
>

0 comments on commit a56cb3d

Please sign in to comment.