diff --git a/fmt/fmt_double.c b/fmt/fmt_double.c index ca7a758..436c431 100644 --- a/fmt/fmt_double.c +++ b/fmt/fmt_double.c @@ -16,6 +16,7 @@ unsigned int fmt_double(char *dest, double d,int maxlen,int prec) { int writeok=(dest!=0); if (s) { d=-d; if (writeok) *dest='-'; --maxlen; dest++; } + if (d==0.0) { if (writeok) *dest='0'; --maxlen; dest++; return dest-oldbuf; } if ((i=e10)>=0) { while (i>10) { tmp=tmp*1e10; i-=10; } while (i>1) { tmp=tmp*10; --i; } diff --git a/t.c b/t.c index c179067..0a38504 100644 --- a/t.c +++ b/t.c @@ -12,10 +12,19 @@ __asm__ __volatile__ ("rdtsc" : "=a" (low) : : "edx") int main(int argc,char* argv[]) { - char buf[100]; + char buf[100]="01234567890123456789012345678901234567890123456789"; + long a,b,c; +#if 0 buf[ip4_fmt(buf,ip4loopback)]=0; buffer_puts(buffer_1small,buf); buffer_flush(buffer_1small); +#endif + + rdtscl(a); + c=str_len(buf); + rdtscl(b); + /*byte_zero_djb(buf,j); */ + printf("\n%lu %d\n",b-a,c); #if 0 buffer_puts(buffer_1small,"hello, world\n"); buffer_flush(buffer_1small);