MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / dropTrailing0

Function dropTrailing0

inst/include/Rcpp/internal/r_coerce.h:188–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

186const char* coerce_to_string( typename ::Rcpp::traits::storage_type<RTYPE>::type from ) ;
187
188inline const char* dropTrailing0(char *s, char cdec) {
189 /* Note that 's' is modified */
190 char *p = s;
191 for (p = s; *p; p++) {
192 if(*p == cdec) {
193 char *replace = p++;
194 while ('0' <= *p && *p <= '9')
195 if(*(p++) != '0')
196 replace = p;
197 if(replace != p)
198 while((*(replace++) = *(p++))) ;
199 break;
200 }
201 }
202 return s;
203}
204
205inline int integer_width( int n ){
206 return n < 0 ? ( (int) ( ::log10( -n+0.5) + 2 ) ) : ( (int) ( ::log10( n+0.5) + 1 ) ) ;

Callers 2

Calls

no outgoing calls

Tested by

no test coverage detected