Skip to content

Friday question: negative zero

2 messages · Jeffrey Horner, Petr Savicky

#
deepayan.sarkar at gmail.com wrote:
Okay, I hope this isn't line noise, but our AMD 64 with R version 2.5.1 
gets:

 > 1/ Im(1/complex(real = -1))
[1] -Inf

 > sessionInfo()
R version 2.5.1 (2007-06-27)
x86_64-pc-linux-gnu

locale:
LC_CTYPE=en_US;LC_NUMERIC=C;LC_TIME=en_US;LC_COLLATE=en_US;LC_MONETARY=en_US;LC_MESSAGES=en_US;LC_PAPER=en_US;LC_NAME=C;LC_ADDRESS=C;LC_TELEPHONE=C;LC_MEASUREMENT=en_US;LC_IDENTIFICATION=C

attached base packages:
[1] "stats"     "graphics"  "grDevices" "utils"     "datasets"  "methods"
[7] "base"

Should I compile R-devel and post the results of the above?

Jeff
#
On Fri, Aug 31, 2007 at 08:39:02PM -0400, Duncan Murdoch wrote:
[snip]
Let me contribute to the statistics over platforms, which already contains
powerpc-apple-darwin8.9.1 (Steven McKinney) and two different results
on AMD 64 (deepayan.sarkar, Jeffrey Horner).

I tried  1/Im(1/complex(real = -1)) on three different platforms, all
of which are Linux, but with different CPU and different gcc version.
In all cases, R-devel_2007-08-31 is used.

The results differ. 

1. [...]$ grep name /proc/cpuinfo
   model name      : Pentium III (Coppermine)
   gcc version 4.0.2 20050901 (prerelease) (SUSE Linux)

   1/Im(1/complex(real = -1)) # Inf

2. [...]$ grep name /proc/cpuinfo
   model name      : Celeron (Coppermine)
   gcc version 4.1.0 (SUSE Linux)

   1/Im(1/complex(real = -1)) # -Inf

3. [...]$ grep name /proc/cpuinfo # two processor machine
   model name      : Intel(R) Xeon(TM) CPU 2.80GHz
   model name      : Intel(R) Xeon(TM) CPU 2.80GHz
   gcc version 3.3.3 20040412 (Red Hat Linux 3.3.3-7)

   1/Im(1/complex(real = -1)) # -Inf

The result does not depend on option -ffloat-store. On Xeon CPU,
it does not depend on, whether SSE (IEEE 754) arithmetic is
used (-march=pentium4 -mfpmath=sse) or not.

Let us try something more.

  z <- complex(real = -1)
  1/Im(z)        # [1] Inf
  1/Im(Conj(z))  # [1] -Inf

  z <- complex(real = -1, imaginary = -0)
  1/Im(z)        # [1] -Inf
  1/Im(Conj(z))  # [1] Inf

These results are consistent across platforms.
Let us look at 1/Im(1/z).

Platform 1 (Pentium III):

  z <- complex(real = -1)
  1/Im(1/z)      # [1] Inf

  z <- complex(real = -1, imaginary = -0)
  1/Im(1/z)      # [1] Inf

Platform 2 (Celeron):

  z <- complex(real = -1)
  1/Im(1/z)      # [1] -Inf

  z <- complex(real = -1, imaginary = -0)
  1/Im(1/z)      # [1] -Inf   (*)

Platform 3 (Xeon):

  z <- complex(real = -1)
  1/Im(1/z)      # [1] -Inf

  z <- complex(real = -1, imaginary = -0)
  1/Im(1/z)      # [1] Inf   (*)

So, besides the first difference between 1 and 2+3,
there is also a difference between 2 and 3 (marked (*)).

Petr Savicky.
===