From murdoch at stats.uwo.ca  Wed May 11 23:27:07 2005
From: murdoch at stats.uwo.ca (Duncan Murdoch)
Date: Wed May 11 23:26:41 2005
Subject: [Rd] bug in modulus operator %% (PR#7852)
In-Reply-To: <20050511202043.5EE3AE187@slim.kubism.ku.dk>
References: <20050511202043.5EE3AE187@slim.kubism.ku.dk>
Message-ID: <428278AB.9070903@stats.uwo.ca>

Robert.McGehee@geodecapital.com wrote:
> Yes, you are correct. I had only checked one of my platforms. Linux
> works as you suggest. But for me on Windows,=20

Certainly looks like a bug on Windows to me.  I'm going offline for a 
day very soon now, but I'll try to remember to look into it.

Duncan Murdoch

> 
> 
>>x <- 1
>>y <- 0.2
>>x %/% y
> 
> [1] 5  ## I get a 4 in Linux
> 
> version
>          _             =20
> platform i386-pc-mingw32
> arch     i386          =20
> os       mingw32       =20
> system   i386, mingw32 =20
> status                 =20
> major    2             =20
> minor    1.0           =20
> year     2005          =20
> month    04            =20
> day      18            =20
> language R             =20
> 
> 
> -----Original Message-----
> From: Peter Dalgaard [mailto:p.dalgaard@biostat.ku.dk]=20
> Sent: Wednesday, May 11, 2005 4:14 PM
> To: McGehee, Robert
> Cc: ted.harding@nessie.mcc.ac.uk; Peter Dalgaard; R-bugs@biostat.ku.dk;
> kjetil@acelerate.com; r-devel@stat.math.ethz.ch
> Subject: Re: [Rd] bug in modulus operator %% (PR#7852)
> 
> 
> "McGehee, Robert" <Robert.McGehee@geodecapital.com> writes:
> 
> 
>>Yes, but from ?"%%":
>>"It is guaranteed that 'x =3D=3D (x %% y) + y * (x %/% y)' (up to =
> 
> rounding
> 
>>error) ..."
>>=20
>>(R 2.1.0)
>>
>>>x <- 1
>>>y <- 0.2
>>>x %% y
>>
>>[1] 0.2
>>
>>>(x %% y) + y * (x %/% y)
>>
>>[1] 1.2
>>=20
>>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?
> 
> --=20
>    O__  ---- Peter Dalgaard             Blegdamsvej 3 =20
>   c/ /'_ --- Dept. of Biostatistics     2200 Cph. N  =20
>  (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
> ~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907
> 
> ______________________________________________
> R-devel@stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] bug in modulus operator %% (PR#7852)
Duncan Murdoch