[Rcpp-commits] r3362 - in pkg/int64: inst/include/int64 src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Nov 16 10:33:06 CET 2011
Author: romain
Date: 2011-11-16 10:33:05 +0100 (Wed, 16 Nov 2011)
New Revision: 3362
Modified:
pkg/int64/inst/include/int64/arith.h
pkg/int64/inst/include/int64/int64.h
pkg/int64/src/int64.cpp
Log:
NA related warning on arithmetic overflow
Modified: pkg/int64/inst/include/int64/arith.h
===================================================================
--- pkg/int64/inst/include/int64/arith.h 2011-11-15 02:01:37 UTC (rev 3361)
+++ pkg/int64/inst/include/int64/arith.h 2011-11-16 09:33:05 UTC (rev 3362)
@@ -39,7 +39,8 @@
T res = x1 + x2 ;
if (res != na && GOODISUM(x1, x2, res)){
return res ;
- }
+ }
+ int64_naflag = true ;
return na ;
}
template <typename T> inline T minus(T x1,T x2){
@@ -51,6 +52,7 @@
if( res != na && GOODIDIFF(x1,x2,res) ){
return res ;
}
+ int64_naflag = true ;
return na ;
}
template <> inline uint64_t minus<uint64_t>( uint64_t x1, uint64_t x2){
@@ -67,6 +69,7 @@
if( res != na && GOODIPROD(x1,x2,res)){
return res ;
}
+ int64_naflag = true ;
return na ;
}
template <typename T> inline T divide(T x1,T x2){
@@ -95,7 +98,7 @@
SEXP arith_long_long(SEXP e1, SEXP e2){
int64::LongVector<LONG> x1( e1 ) ;
int64::LongVector<LONG> x2( e2 ) ;
-
+ int64_naflag = false ;
int n1 = x1.size(), n2 = x2.size();
LONG tmp ;
int i1 = 0, i2 = 0, i = 0 ;
@@ -122,6 +125,7 @@
res.set( i, Fun( x1.get(i1), x2.get(i2) ) ) ;
}
}
+ if( int64_naflag ) Rf_warning( "NAs produced by integer overflow" ) ;
return res ;
}
Modified: pkg/int64/inst/include/int64/int64.h
===================================================================
--- pkg/int64/inst/include/int64/int64.h 2011-11-15 02:01:37 UTC (rev 3361)
+++ pkg/int64/inst/include/int64/int64.h 2011-11-16 09:33:05 UTC (rev 3362)
@@ -24,6 +24,8 @@
namespace int64{
namespace internal {
SEXP int2(int,int) ;
+
+ bool int64_naflag = false ;
}
}
Modified: pkg/int64/src/int64.cpp
===================================================================
--- pkg/int64/src/int64.cpp 2011-11-15 02:01:37 UTC (rev 3361)
+++ pkg/int64/src/int64.cpp 2011-11-16 09:33:05 UTC (rev 3362)
@@ -192,7 +192,6 @@
int n = Rf_length(s_) ;
int* digits = INTEGER(digits_) ;
int* len = INTEGER(len_) ;
- int tmp = 0 ;
SEXP res = PROTECT( Rf_allocVector( STRSXP, n ) ) ;
for( int i=0; i<n; i++){
More information about the Rcpp-commits
mailing list