1.1 --- a/templates/native.c Thu Dec 01 19:48:31 2016 +0100
1.2 +++ b/templates/native.c Thu Dec 01 21:23:11 2016 +0100
1.3 @@ -1,4 +1,4 @@
1.4 -#include <stdlib.h> /* exit */
1.5 +#include <stdlib.h> /* abs, exit */
1.6 #include <unistd.h> /* read, write */
1.7 #include <math.h> /* ceil, log10, pow */
1.8 #include <string.h> /* strcmp, strncpy, strlen */
1.9 @@ -281,7 +281,7 @@
1.10 __attr * const self = &__args[1];
1.11 /* self.__data__ interpreted as int */
1.12 int i = __load_via_object(self->value, __pos___data__).intvalue;
1.13 - int n = i != 0 ? (int) ceil(log10(i+1)) + 1 : 2;
1.14 + int n = i != 0 ? (int) ceil(log10(abs(i)+1)) + 1 : 2;
1.15 char *s = (char *) __ALLOCATE(n, sizeof(char));
1.16
1.17 if (i < 0) n++;