From p.dalgaard at biostat.ku.dk  Wed May 11 22:14:06 2005
From: p.dalgaard at biostat.ku.dk (Peter Dalgaard)
Date: Wed May 11 22:14:15 2005
Subject: [Rd] bug in modulus operator %% (PR#7852)
In-Reply-To: <67DCA285A2D7754280D3B8E88EB548020C9465BE@MSGBOSCLB2WIN.DMN1.FMR.COM>
References: <67DCA285A2D7754280D3B8E88EB548020C9465BE@MSGBOSCLB2WIN.DMN1.FMR.COM>
Message-ID: <x264xpplkh.fsf@turmalin.kubism.ku.dk>

"McGehee, Robert" <Robert.McGehee@geodecapital.com> writes:

> Yes, but from ?"%%":
> "It is guaranteed that 'x == (x %% y) + y * (x %/% y)' (up to rounding
> error) ..."
> 
> (R 2.1.0)
> > x <- 1
> > y <- 0.2
> > x %% y
> [1] 0.2
> > (x %% y) + y * (x %/% y)
> [1] 1.2
> 
> Certainly 1 does not equal 1.2 as the documentation would suggest, and
> these seem like large enough numbers to not be effected by rounding
> errors or lack of precision.

Now that looks a bit odd, but it isn't universal:

> x <- 1
> y <- 0.2
> x %% y
[1] 0.2
> x %/% y
[1] 4
> (x %% y) + y * (x %/% y)
[1] 1

So what platform was that happening on?

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907


[Rd] bug in modulus operator %% (PR#7852)
Peter Dalgaard