Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upReduce -Wconversion warnings for sugar code #688
Conversation
| @@ -133,7 +133,8 @@ inline Vector<STRSXP> trimws(const Vector<STRSXP>& x, const char* which = "both" | |||
| } | |||
|
|
|||
| inline Matrix<STRSXP> trimws(const Matrix<STRSXP>& x, const char* which = "both") { | |||
| R_xlen_t i = 0, nr = x.nrow(), nc = x.ncol(), sz = x.size(); | |||
| R_xlen_t i = 0, sz = x.size(); | |||
| int nr = x.nrow(), nc = x.ncol(); | |||
eddelbuettel
May 5, 2017
Member
Just double-checking here: Even with R_xlen_t, rows and cols are still int in R itself, but number of matrix elements can exceed int. Do I have that correct?
Just double-checking here: Even with R_xlen_t, rows and cols are still int in R itself, but number of matrix elements can exceed int. Do I have that correct?
coatless
May 5, 2017
•
Contributor
Per https://stat.ethz.ch/R-manual/R-devel/library/base/html/LongVectors.html
Arrays (including matrices) can be based on long vectors provided each of their dimensions is at most 2^31 - 1:
Type
Storage size
Value range
int
2 or 4 bytes
-32,768 to 32,767 or -2,147,483,648 to 2,147,483,647
In theory, you are bounded by: (2^31 - 1)^2 = 4,611,686,014,132,420,609
Per https://stat.ethz.ch/R-manual/R-devel/library/base/html/LongVectors.html
Arrays (including matrices) can be based on long vectors provided each of their dimensions is at most 2^31 - 1:
| Type | Storage size | Value range |
|---|---|---|
| int | 2 or 4 bytes | -32,768 to 32,767 or -2,147,483,648 to 2,147,483,647 |
In theory, you are bounded by: (2^31 - 1)^2 = 4,611,686,014,132,420,609
eddelbuettel
May 5, 2017
Member
Me too, was just trying to confirm. Because otherwise nrow, ncol should not be int here and in Matrix.
Have a test running with the now-merged PR. Things take some time of course.
Me too, was just trying to confirm. Because otherwise nrow, ncol should not be int here and in Matrix.
Have a test running with the now-merged PR. Things take some time of course.
eddelbuettel
May 5, 2017
•
Member
Not uint though. R only uses signed ints.
Not uint though. R only uses signed ints.
eddelbuettel
May 5, 2017
Member
R> .Machine$integer.max
[1] 2147483647
R>
R> .Machine$integer.max
[1] 2147483647
R>
coatless
May 5, 2017
Contributor
Quoted the 2byte bounds instead of 4byte blah.
Quoted the 2byte bounds instead of 4byte blah.
Codecov Report
@@ Coverage Diff @@
## master #688 +/- ##
=======================================
Coverage 89.77% 89.77%
=======================================
Files 66 66
Lines 3511 3511
=======================================
Hits 3152 3152
Misses 359 359Continue to review full report at Codecov.
|
|
Looks good to me. Let's get a second nod from someone and I'll put it in. |
|
Tests are good so far (just committed for #687) so in it goes with a fresh test. |
2/n.