fmt_double looped inifinitely when trying to format 0.
This commit is contained in:
parent
dc60cb52bd
commit
99bc1eb7e4
@ -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; }
|
||||
|
11
t.c
11
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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user