瀏覽代碼

fix ecvt/fcvt decimal point position output

these functions are obsolete and have no modern standard. the text in
SUSv2 is highly ambiguous, specifying that "negative means to the left
of the returned digits", which suggested to me that 0 would mean to
the right of the first digit. however, this does not agree with
historic practice, and the Linux man pages are more clear, specifying
that a negative value means "that the decimal point is to the left of
the start of the string" (in which case, 0 would mean the start of the
string, in accordance with historic practice).
Rich Felker 11 年之前
父節點
當前提交
a0cc022cc7
共有 1 個文件被更改,包括 1 次插入1 次删除
  1. 1 1
      src/stdlib/ecvt.c

+ 1 - 1
src/stdlib/ecvt.c

@@ -13,7 +13,7 @@ char *ecvt(double x, int n, int *dp, int *sign)
 	for (j=0; tmp[i]!='e'; j+=(tmp[i++]!='.'))
 		buf[j] = tmp[i];
 	buf[j] = 0;
-	*dp = atoi(tmp+i+1);
+	*dp = atoi(tmp+i+1)+1;
 
 	return buf;
 }