From a56cb3dcad5f937a37a160fe746b175111490b4d Mon Sep 17 00:00:00 2001 From: ripley Date: Sun, 29 Jan 2012 09:37:54 +0000 Subject: [PATCH] add test for sqrt(-0) git-svn-id: https://svn.r-project.org/R/trunk@58223 00db46b3-68df-0310-9c12-caf00c1e9a41 --- tests/iec60559.R | 6 ++++++ tests/iec60559.Rout.save | 12 ++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/tests/iec60559.R b/tests/iec60559.R index 2297ef039dd..1eec8b487de 100644 --- a/tests/iec60559.R +++ b/tests/iec60559.R @@ -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)) diff --git a/tests/iec60559.Rout.save b/tests/iec60559.Rout.save index 5f144405851..ec07d29a666 100644 --- a/tests/iec60559.Rout.save +++ b/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. @@ -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 +>