version comparison puzzle

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

version comparison puzzle

bbolker

     Can anyone explain what I'm missing here?

max(pp1 <- package_version(c("0.99999911.3","1.0.4","1.0.5")))
## [1] ‘1.0.4’

max(pp2 <- package_version(c("1.0.3","1.0.4","1.0.5")))
## [1] ‘1.0.5’

I've looked at ?package_version , to no avail.

Since max() goes to .Primitive("max")
I'm having trouble figuring out where it goes from there:
I **think** this is related to ?xtfrm , which goes to
.encode_numeric_version, which is doing something I really
don't understand (it's in base/R/version.R ...)

.encode_numeric_version(pp1)
## [1] 1 1 1
## attr(,"base")
## [1] 99999912
## attr(,"lens")
## [1] 3 3 3
## attr(,".classes")
## [1] "package_version" "numeric_version"

.encode_numeric_version(pp2)
## [1] 1.083333 1.111111 1.138889
## attr(,"base")
## [1] 6
## attr(,"lens")
## [1] 3 3 3
## attr(,".classes")
## [1] "package_version" "numeric_version"

sessionInfo()
R Under development (unstable) (2013-09-09 r63889)
Platform: i686-pc-linux-gnu (32-bit)

[snip]

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

loaded via a namespace (and not attached):
[1] compiler_3.1.0 tools_3.1.0

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: version comparison puzzle

Martyn Plummer-3
It's an underflow problem. When comparing versions, "a.b.c" is converted
first to the integer vector c(a,b,c) and then to the double precision
value

a + b/base + c/base^2

where base is 1 greater than the largest integer component of any of the
versions: i.e 999999912 in this case.  The last term is then smaller
than the machine precision so you can't tell the difference between
1.0.4 and 1.0.5.

Martyn

On Wed, 2013-10-02 at 23:41 -0400, Ben Bolker wrote:

>      Can anyone explain what I'm missing here?
>
> max(pp1 <- package_version(c("0.99999911.3","1.0.4","1.0.5")))
> ## [1] ‘1.0.4’
>
> max(pp2 <- package_version(c("1.0.3","1.0.4","1.0.5")))
> ## [1] ‘1.0.5’
>
> I've looked at ?package_version , to no avail.
>
> Since max() goes to .Primitive("max")
> I'm having trouble figuring out where it goes from there:
> I **think** this is related to ?xtfrm , which goes to
> .encode_numeric_version, which is doing something I really
> don't understand (it's in base/R/version.R ...)
>
> .encode_numeric_version(pp1)
> ## [1] 1 1 1
> ## attr(,"base")
> ## [1] 99999912
> ## attr(,"lens")
> ## [1] 3 3 3
> ## attr(,".classes")
> ## [1] "package_version" "numeric_version"
>
> .encode_numeric_version(pp2)
> ## [1] 1.083333 1.111111 1.138889
> ## attr(,"base")
> ## [1] 6
> ## attr(,"lens")
> ## [1] 3 3 3
> ## attr(,".classes")
> ## [1] "package_version" "numeric_version"
>
> sessionInfo()
> R Under development (unstable) (2013-09-09 r63889)
> Platform: i686-pc-linux-gnu (32-bit)
>
> [snip]
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> loaded via a namespace (and not attached):
> [1] compiler_3.1.0 tools_3.1.0
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Reply | Threaded
Open this post in threaded view
|

Re: version comparison puzzle

Jari Oksanen
Actually, Bob O'Hara had a blog post about this in August 2012:

http://occamstypewriter.org/boboh/2012/08/17/lme4_destined_to_become_stable_through_rounding/

The concluding chapter reads:

"I have been worried that lme4 will never become stable, but this latest version mollifies me with the thought that the developers can’t go on forever, so eventually lme4 will become stable when the machine precision forces it to be rounded up to 1.0"

Cheers, Jari Oksanen
________________________________________
From: [hidden email] [[hidden email]] on behalf of Martyn Plummer [[hidden email]]
Sent: 03 October 2013 11:15
To: Ben Bolker
Cc: [hidden email]
Subject: Re: [Rd] version comparison puzzle

It's an underflow problem. When comparing versions, "a.b.c" is converted
first to the integer vector c(a,b,c) and then to the double precision
value

a + b/base + c/base^2

where base is 1 greater than the largest integer component of any of the
versions: i.e 999999912 in this case.  The last term is then smaller
than the machine precision so you can't tell the difference between
1.0.4 and 1.0.5.

Martyn

On Wed, 2013-10-02 at 23:41 -0400, Ben Bolker wrote:

>      Can anyone explain what I'm missing here?
>
> max(pp1 <- package_version(c("0.99999911.3","1.0.4","1.0.5")))
> ## [1] ‘1.0.4’
>
> max(pp2 <- package_version(c("1.0.3","1.0.4","1.0.5")))
> ## [1] ‘1.0.5’
>
> I've looked at ?package_version , to no avail.
>
> Since max() goes to .Primitive("max")
> I'm having trouble figuring out where it goes from there:
> I **think** this is related to ?xtfrm , which goes to
> .encode_numeric_version, which is doing something I really
> don't understand (it's in base/R/version.R ...)
>
> .encode_numeric_version(pp1)
> ## [1] 1 1 1
> ## attr(,"base")
> ## [1] 99999912
> ## attr(,"lens")
> ## [1] 3 3 3
> ## attr(,".classes")
> ## [1] "package_version" "numeric_version"
>
> .encode_numeric_version(pp2)
> ## [1] 1.083333 1.111111 1.138889
> ## attr(,"base")
> ## [1] 6
> ## attr(,"lens")
> ## [1] 3 3 3
> ## attr(,".classes")
> ## [1] "package_version" "numeric_version"
>
> sessionInfo()
> R Under development (unstable) (2013-09-09 r63889)
> Platform: i686-pc-linux-gnu (32-bit)
>
> [snip]
>
> attached base packages:
> [1] stats     graphics  grDevices utils     datasets  methods   base
>
> loaded via a namespace (and not attached):
> [1] compiler_3.1.0 tools_3.1.0
>
> ______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel