Skip to content

strange behavior of print vs. round

1 message · William Revelle

#
Dear friends,
   I have discovered what I find peculiar behavior of print.  In 
general, print with n digits agrees with round with n digits.

Although printing all the elements of a vector with digits=2 gives 
the expected results, printing a single element of the vector does 
not.
[1] 0.194 0.294 0.394 0.494 0.594 0.694 0.794 0.894 0.994
[1] 0.19 0.29 0.39 0.49 0.59 0.69 0.79 0.89 0.99
[1] 0.19
[1] 0.29
[1] 0.39
[1] 0.49
[1] 0.59
[1] 0.7
[1] 0.8
[1] 0.9
[1] 1

#     But this is not a problem with round .
[1] 0.19
[1] 0.29
[1] 0.39
[1] 0.49
[1] 0.59
[1] 0.69
[1] 0.79
[1] 0.89
[1] 0.99
R version 2.8.1 Patched (2008-12-31 r47414)
i386-apple-darwin8.11.1

locale:
en_US.UTF-8/en_US.UTF-8/C/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] psych_1.0-64

loaded via a namespace (and not attached):
[1] tools_2.8.1

Bill