[R] Why is 0 not an integer?

William Dunlap wdunlap at tibco.com
Fri Aug 7 00:06:08 CEST 2009


> -----Original Message-----
> From: r-help-bounces at r-project.org 
> [mailto:r-help-bounces at r-project.org] On Behalf Of Giovanni Petris
> Sent: Thursday, August 06, 2009 3:00 PM
> To: milton.ruser at gmail.com
> Cc: r-help at r-project.org; Daniel.Gerlanc at geodecapital.com
> Subject: Re: [R] Why is 0 not an integer?
> 
> 
> I ran an instant experiment...
> 
> > typeof(0)
> [1] "double"
> > typeof(-0)
> [1] "double"
> > identical(0, -0)
> [1] TRUE
> 
> Best,
> Giovanni

But 0.0 and -0.0 have different reciprocals

   > 1.0/0.0
   [1] Inf
   > 1.0/-0.0
   [1] -Inf

Bill Dunlap
TIBCO Software Inc - Spotfire Division
wdunlap tibco.com  

> 
> > By the way:
> > 
> > Are there difference between -0 and 0?
> 
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide 
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
> 




More information about the R-help mailing list