<commit_before>#ifndef NOFLOAT
extern double modf();
static char *cvt();
#define NDIGITS	128

char *
ecvt(value, ndigit, decpt, sign)
	double value;
	int ndigit, *decpt, *sign;
{
	return cvt(value, ndigit, decpt, sign, 1);
}

char *
fcvt(value, ndigit, decpt, sign)
	double value;
	int ndigit, *decpt, *sign;
{
	return cvt(value, ndigit, decpt, sign, 0);
}

static char *
cvt(value, ndigit, decpt, sign, ecvtflag)
	double value;
	int ndigit, *decpt, *sign;
{
	double intpart, fractpart;
	static char buf[NDIGITS];
	char buf1[NDIGITS];
	register char *pe = buf1;
	register  char *pb;
	int pointpos = 0;


	if (ndigit < 0) ndigit = 0;
	if (ndigit >= NDIGITS - 10) ndigit = NDIGITS - 11;

	*sign = 0;
	if (value < 0) {
		*sign = 1;
		value = -value;
	}

	fractpart = modf(value, &intpart);
	if (intpart != 0) {
		do {	/* get digits of integer part, low order digit
			   first
			*/
			value = modf(intpart/10, &intpart);
			/* compensate for rounding errors, because
			   the conversion to "int" truncates
			*/
			if (pe >= &buf1[NDIGITS]) {
				pb = &buf1[NDIGITS-10];
				while (pb > buf1) *--pb = *--pe;
				pe = &buf[NDIGITS-10];
			}
			*pe++ = (int)((value+.05) * 10) + '0';
			pointpos++;
		} while (intpart != 0);
		while (pe > buf1) *pb++ = *--pe;
	}
	else if (value > 0) {
		fractpart = value;
		while ((value = value*10) < 1) {
			fractpart = value;
			pointpos--;
		}
		pb = &buf[0];
	}
	pe = &buf[ndigit];
	if (! ecvtflag) {
		/* for fcvt() we need ndigit digits behind the dot */
		pe += pointpos;
		if (pe < buf) {
			/* pointpos was too far left of the beginning */
			buf[0] = 0;
			*decpt = pointpos;
			return buf;
		}
		if (pe > &buf[NDIGITS]) pe = &buf[NDIGITS];
	}
	while (pb <= pe) {
		fractpart = modf(fractpart * 10, &value);
		*pb++ = (int)value + '0';
	}
	pb = pe;
	*pb += 5;	/* round of at the end */
	while (*pb > '9') {
		*pb = '0';
		if (pb > buf) ++*--pb;
		else {
			*pb = '1';
			pointpos++;
			if (! ecvtflag) {
				/* maybe add another digit at the end,
				   because the point was shifted right
				*/
				if (pe > buf) *pe = '0';
				pe++;
			}
		}
	}
	*decpt = pointpos;
	*pe = '\0';
	return(buf);
}
#endif<commit_msg>bug fix<commit_after>#ifndef NOFLOAT
extern double modf();
static char *cvt();
#define NDIGITS	128

char *
ecvt(value, ndigit, decpt, sign)
	double value;
	int ndigit, *decpt, *sign;
{
	return cvt(value, ndigit, decpt, sign, 1);
}

char *
fcvt(value, ndigit, decpt, sign)
	double value;
	int ndigit, *decpt, *sign;
{
	return cvt(value, ndigit, decpt, sign, 0);
}

static char *
cvt(value, ndigit, decpt, sign, ecvtflag)
	double value;
	int ndigit, *decpt, *sign;
{
	double intpart, fractpart;
	static char buf[NDIGITS];
	char buf1[NDIGITS];
	register char *pe = buf1;
	register  char *pb;
	int pointpos = 0;


	if (ndigit < 0) ndigit = 0;
	if (ndigit >= NDIGITS - 10) ndigit = NDIGITS - 11;

	*sign = 0;
	if (value < 0) {
		*sign = 1;
		value = -value;
	}

	fractpart = modf(value, &intpart);
	if (intpart != 0) {
		do {	/* get digits of integer part, low order digit
			   first
			*/
			value = modf(intpart/10, &intpart);
			/* compensate for rounding errors, because
			   the conversion to "int" truncates
			*/
			if (pe >= &buf1[NDIGITS]) {
				pb = &buf1[NDIGITS-10];
				while (pb > buf1) *--pb = *--pe;
				pe = &buf[NDIGITS-10];
			}
			*pe++ = (int)((value+.05) * 10) + '0';
			pointpos++;
		} while (intpart != 0);
		pb = buf;
		while (pe > buf1) *pb++ = *--pe;
	}
	else if (value > 0) {
		fractpart = value;
		while ((value = value*10) < 1) {
			fractpart = value;
			pointpos--;
		}
		pb = &buf[0];
	}
	pe = &buf[ndigit];
	if (! ecvtflag) {
		/* for fcvt() we need ndigit digits behind the dot */
		pe += pointpos;
		if (pe < buf) {
			/* pointpos was too far left of the beginning */
			buf[0] = 0;
			*decpt = pointpos;
			return buf;
		}
		if (pe > &buf[NDIGITS]) pe = &buf[NDIGITS];
	}
	while (pb <= pe) {
		fractpart = modf(fractpart * 10, &value);
		*pb++ = (int)value + '0';
	}
	pb = pe;
	*pb += 5;	/* round of at the end */
	while (*pb > '9') {
		*pb = '0';
		if (pb > buf) ++*--pb;
		else {
			*pb = '1';
			pointpos++;
			if (! ecvtflag) {
				/* maybe add another digit at the end,
				   because the point was shifted right
				*/
				if (pe > buf) *pe = '0';
				pe++;
			}
		}
	}
	*decpt = pointpos;
	*pe = '\0';
	return buf;
}
#endif
{'fraction_non_alphanumeric': 0.1777366350381856, 'fraction_numerical': 0.023142791020597082, 'mean_word_length': 2.719449225473322, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1846746', 'n_tokens_mistral': 2078, 'n_tokens_neox': 1798, 'n_words': 527}