Skip to content

Commit 4766b9c

Browse files
committed
explicitly convert occurrences of "-0" to "0"
1 parent add1817 commit 4766b9c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

inst/include/Rcpp/internal/r_coerce.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ inline const char* coerce_to_string<REALSXP>(double x){
238238
// so approximate it poorly as
239239
static char tmp[128];
240240
snprintf(tmp, 127, "%f", x);
241-
return dropTrailing0(tmp, '.');
241+
if (strcmp( dropTrailing0(tmp, '.'), "-0") == 0) return "0";
242+
else return dropTrailing0(tmp, '.');
242243
}
243244
#define NB 1000
244245
template <>

0 commit comments

Comments
 (0)