0

I got these using R, which is strange

> 1000^(2/3)
[1] 100
> dim(matrix(NA,100,1000^(2/3)))
[1] 100  99
> dim(matrix(NA,100,100))
[1] 100 100
lmo
  • 37,904
  • 9
  • 56
  • 69
Roy C
  • 197
  • 2
  • 12
  • 4
    Technically, this could be a duplicate of [this](http://stackoverflow.com/q/9508518/324364). When you pass a non-integer dimension to `matrix` it essentially appears to take the `floor` of it. – joran Nov 05 '15 at 21:28
  • 1
    ...it probably would be nice if this behavior was mentioned in `?matrix`, as my quick reading suggests it is not. – joran Nov 05 '15 at 21:29
  • @joran But 1000^(2/3) is an integer, floor does no difference. – Roy C Nov 05 '15 at 21:31
  • 1
    @joran Yeah, they could add something like what `?rep` has `"Non-integer values of [arg] will be truncated towards zero."` – Frank Nov 05 '15 at 21:32
  • 1
    Anticipating your somewhat mangled comment, run `1000^(2/3) == 100` and then `options(digits = 16); 1000^(2/3)`. It is mathematically an integer, but all computers fail to represent all numbers exactly, as discussed in great detail at my link. – joran Nov 05 '15 at 21:33
  • @R.Chen : `class(1000^(2/3))` and `1000^(2/3) -100` ! – jogo Nov 05 '15 at 21:45
  • Interesting. Thank you. – Roy C Nov 05 '15 at 21:49

0 Answers0