JS_cnvtf(char *buf,int bufsz, int prcsn,double fval)
JS_cnvtf(char *buf, size_t bufsz, int prcsn, double fval)
JS_FRIEND_API(void)JS_cnvtf(char *buf,int bufsz, int prcsn,double fval){    intN decpt,sign,numdigits;    char *num, *nump;    char *bufp = buf;    char *endnum;	/* If anything fails, we store an empty string in 'buf' */	num = (char *)MALLOC(bufsz);	if (num == NULL) {		buf[0] = '\0';		return;	}	/* XXX Why use mode 1? */	if (JS_dtoa(fval,1,prcsn,&decpt,&sign,&endnum,num,bufsz)			== JS_FALSE) {		buf[0] = '\0';		goto done;	}	numdigits = endnum - num;	nump = num;	/* If negative and not signed zero and not a NaN, print leading "-". */	if (sign &&	    !(word0(fval) == Sign_bit && word1(fval) == 0) &&	    !((word0(fval) & Exp_mask) == Exp_mask &&	      (word1(fval) || (word0(fval) & 0xfffff)))) {	    *bufp++ = '-';	}	if(decpt == 9999){		while((*bufp++ = *nump++) != 0) ;		goto done;	}	if(decpt > (prcsn+1) || decpt < -(prcsn-1) || decpt < -5){	    *bufp++ = *nump++;	    if(numdigits != 1){			*bufp++ = '.';	    }	    while(*nump != '\0'){			*bufp++ = *nump++;	    }	    *bufp++ = 'e';	    JS_snprintf(bufp,bufsz - (bufp - buf), "%+d",decpt-1);	}	else if(decpt >= 0){	    if (decpt == 0){			*bufp++ = '0';	    }	    else {		while(decpt--){			if(*nump != '\0'){				*bufp++ = *nump++;			}			else {				*bufp++ = '0';			}		}	    }	    if(*nump != '\0'){			*bufp++ = '.';			while(*nump != '\0'){				*bufp++ = *nump++;			}	    }	    *bufp++ = '\0';	}	else if(decpt < 0){	    *bufp++ = '0';	    *bufp++ = '.';	    while(decpt++){			*bufp++ = '0';	    }	    	    while(*nump != '\0'){			*bufp++ = *nump++;	    }	    *bufp++ = '\0';	}done:        free(num);}