rounding change

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

rounding change

R devel mailing list
This is a small heads up for package maintainers.   Under the more recent R-devel, R CMD
check turned up some changes in the *.out files.   The simple demonstration is to type 
"round(51/80, 3)", which gives .638 under the old and .637 under the new.   (One of my
coxph test cases has a concordance of exactly 51/80).

In this particular case 51/80 is exactly .63750000, but that value does not have an exact
representation in base 2.  The line below would argue that the new version is correct, at
least with respect to the internal representation.

 > print(51/80, digits = 20)
[1] 0.63749999999999995559

This is not a bug or problem, it just means that whichever version I put into my
survival/tests/book6.Rout.save file, one of R-devel or R-current will flag an issue.



        [[alternative HTML version deleted]]

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

Re: rounding change

Hervé Pagès-2
Thanks for the heads up. The new result for round(51/80, digits=3) is
also consistent with sprintf("%.3f", 51/80), format(51/80, digits=3),
print(51/80, digits=3), and with the sprintf() function in C. Which is
somehow satisfying.

H.

On 3/5/20 05:54, Therneau, Terry M., Ph.D. via R-devel wrote:

> This is a small heads up for package maintainers.   Under the more recent R-devel, R CMD
> check turned up some changes in the *.out files.   The simple demonstration is to type
> "round(51/80, 3)", which gives .638 under the old and .637 under the new.   (One of my
> coxph test cases has a concordance of exactly 51/80).
>
> In this particular case 51/80 is exactly .63750000, but that value does not have an exact
> representation in base 2.  The line below would argue that the new version is correct, at
> least with respect to the internal representation.
>
>   > print(51/80, digits = 20)
> [1] 0.63749999999999995559
>
> This is not a bug or problem, it just means that whichever version I put into my
> survival/tests/book6.Rout.save file, one of R-devel or R-current will flag an issue.
>
>
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> [hidden email] mailing list
> https://urldefense.proofpoint.com/v2/url?u=https-3A__stat.ethz.ch_mailman_listinfo_r-2Ddevel&d=DwIDaQ&c=eRAMFD45gAfqt84VtBcfhQ&r=BK7q3XeAvimeWdGbWY_wJYbW0WYiZvSXAJJKaaPhzWA&m=ByODf3XxvkT0Ag-YiS72sOZMg3b9vKH-pDRcZARaGWQ&s=z5huvy_ZadTqpmI7_sfnFcohmR_I4LdQ3LmOjyEg6kw&e=
>

--
Hervé Pagès

Program in Computational Biology
Division of Public Health Sciences
Fred Hutchinson Cancer Research Center
1100 Fairview Ave. N, M1-B514
P.O. Box 19024
Seattle, WA 98109-1024

E-mail: [hidden email]
Phone:  (206) 667-5791
Fax:    (206) 667-1319

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