소스 검색

make fcvt decimal point location for zero make more sense

the (obsolete) standard allows either 0 or 1 for the decimal point
location in this case, but since the number of zero digits returned in
the output string (in this implementation) is one more than the number
of digits the caller requested, it makes sense for the decimal point
to be logically "after" the first digit. in a sense, this change goes
with the previous commit which fixed the value of the decimal point
location for non-zero inputs.
Rich Felker 11 년 전
부모
커밋
983acebc8a
1개의 변경된 파일1개의 추가작업 그리고 1개의 파일을 삭제
  1. 1 1
      src/stdlib/fcvt.c

+ 1 - 1
src/stdlib/fcvt.c

@@ -16,7 +16,7 @@ char *fcvt(double x, int n, int *dp, int *sign)
 
 	if (n<=lz) {
 		*sign = i;
-		*dp = 0;
+		*dp = 1;
 		if (n>14U) n = 14;
 		return "000000000000000"+14-n;
 	}