[Rcpp-commits] r4323 - in pkg/Rcpp: . src

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Sun May 26 21:52:23 CEST 2013


Author: edd
Date: 2013-05-26 21:52:22 +0200 (Sun, 26 May 2013)
New Revision: 4323

Modified:
   pkg/Rcpp/ChangeLog
   pkg/Rcpp/src/api.cpp
Log:
Minor tweak for internal formatting


Modified: pkg/Rcpp/ChangeLog
===================================================================
--- pkg/Rcpp/ChangeLog	2013-05-24 21:53:33 UTC (rev 4322)
+++ pkg/Rcpp/ChangeLog	2013-05-26 19:52:22 UTC (rev 4323)
@@ -1,3 +1,7 @@
+2013-05-26  Dirk Eddelbuettel  <edd at debian.org>
+
+	* src/api.cpp: Minor tweak for internal formatting
+
 2013-05-24  J.J. Allaire <jj at rstudio.org>
 
         * R/Attributes.R: Disallow compilation for files that don't have

Modified: pkg/Rcpp/src/api.cpp
===================================================================
--- pkg/Rcpp/src/api.cpp	2013-05-24 21:53:33 UTC (rev 4322)
+++ pkg/Rcpp/src/api.cpp	2013-05-26 19:52:22 UTC (rev 4323)
@@ -1767,8 +1767,7 @@
     //     char* tmp = const_cast<char*>( Rf_EncodeReal(x, w, d, e, '.') );
     // so approximate it poorly as
     static char tmp[128];
-    //snprintf(tmp, 127, "%*.*f", w, d, x);
-    snprintf(tmp, 127, "%f", x); // FIXME: barebones defaults
+    snprintf(tmp, 127, "%f", x); 
     return dropTrailing0(tmp, '.');
 }
 
@@ -1778,10 +1777,13 @@
     // we are no longer allowed to use this:
     //     Rf_EncodeComplex(x, wr, dr, er, wi, di, ei, '.' );
     // so approximate it poorly as
-    static char tmp[128];
+    static char tmp1[128], tmp2[128], tmp3[256];
     //snprintf(tmp, 127, "%*.*f+%*.*fi", wr, dr, x.r, wi, di, x.i);
-    snprintf(tmp, 127, "%*.*f+%*.*fi", x.r, x.i); // FIXEM: barebones default formatting
-    return tmp;
+    //snprintf(tmp, 127, "%f+%fi", x.r, x.i); // FIXEM: barebones default formatting
+    snprintf(tmp1, 127, "%f", x.r); 
+    snprintf(tmp2, 127, "%f", x.i); 
+    snprintf(tmp3, 255, "%s+%si", dropTrailing0(tmp1, '.'), dropTrailing0(tmp2, '.'));
+    return tmp3;
 }
 
 } // internal



More information about the Rcpp-commits mailing list