[Rcpp-commits] r1097 - pkg/Rcpp/src
noreply at r-forge.r-project.org
noreply at r-forge.r-project.org
Wed Apr 21 15:37:58 CEST 2010
Author: romain
Date: 2010-04-21 15:37:58 +0200 (Wed, 21 Apr 2010)
New Revision: 1097
Modified:
pkg/Rcpp/src/RcppDatetime.cpp
Log:
not using round which is not part of c++
Modified: pkg/Rcpp/src/RcppDatetime.cpp
===================================================================
--- pkg/Rcpp/src/RcppDatetime.cpp 2010-04-21 10:09:01 UTC (rev 1096)
+++ pkg/Rcpp/src/RcppDatetime.cpp 2010-04-21 13:37:58 UTC (rev 1097)
@@ -22,6 +22,13 @@
#include <RcppDatetime.h>
#include <time.h> // for strftime
+static int rcpp_round( double x ){
+ int y = static_cast<int>(x);
+ double diff = x - y ;
+ if( diff >= 0.5 ) y++ ;
+ return y ;
+}
+
RcppDatetime::RcppDatetime(void) : m_d(0),
m_parsed(false),
m_us(0) {
@@ -44,7 +51,7 @@
m_tm = *localtime(&tt); // parse time type into time structure
// m_us is fractional (micro)secs is diff. between (fractional) m_d and m_tm
- m_us = static_cast<int>(round( (m_d - tt) * 1.0e6));
+ m_us = rcpp_round( (m_d - tt) * 1.0e6);
m_parsed = true; // and note that we parsed the time type
}
More information about the Rcpp-commits
mailing list