Skip to content
Prev 273845 / 398506 Next

round() and negative digits

On 08-Oct-11 21:39:07, Duncan Murdoch wrote:
A Fortunate remark??

That being said -- if such are your intentions, then over
my dead body ...

Carl Witthoft's serendipitous discovery is a nice example
of how secrets can be guessed by wondering "what if ... ?".
So probably you don;t need to tell the secrets.

Taking the "negative digits" to their logical extreme:

  round(654.321,2)
  # [1] 654.32
  round(654.321,1)
  # [1] 654.3
  round(654.321,0)
  # [1] 654
  round(654.321,-1)
  # [1] 650
  round(654.321,-2)
  # [1] 700
  round(654.321,-3)
  # [1] 1000
  round(654.321,-4)
  # [1] 0

which is what you'd logically expect (but is it what you
would intuitively expect?).

Ted.

--------------------------------------------------------------------
E-Mail: (Ted Harding) <ted.harding at wlandres.net>
Fax-to-email: +44 (0)870 094 0861
Date: 08-Oct-11                                       Time: 23:11:27
------------------------------ XFMail ------------------------------