#include "num.h" num num_tostring_nonneg(char *s,num x) { num len = 1; num q = x; if (x < 0) return 0; while (q > 9) { ++len; q /= 10; } if (s) { s += len; do { *--s = '0' + (x % 10); x /= 10; } while(x); } return len; }