Browse Source

fmt_double looped inifinitely when trying to format 0.

master
Felix von Leitner 19 years ago
parent
commit
047ed33b8f
2 changed files with 11 additions and 1 deletions
  1. +1
    -0
      fmt/fmt_double.c
  2. +10
    -1
      t.c

+ 1
- 0
fmt/fmt_double.c View File

@@ -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; }


+ 10
- 1
t.c View File

@@ -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);


Loading…
Cancel
Save