aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2013-08-07 11:19:11 -0400
committerRich Felker <dalias@aerifal.cx>2013-08-07 11:19:11 -0400
commit983acebc8a22866f720fbdb60aadc2a9c074d8f1 (patch)
tree4a3d16266b47d5c06aaa79b60d3e807a8bc1eb36
parentfix ecvt/fcvt decimal point position output (diff)
downloadgrovel-983acebc8a22866f720fbdb60aadc2a9c074d8f1.tar.gz
grovel-983acebc8a22866f720fbdb60aadc2a9c074d8f1.tar.xz
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.
-rw-r--r--src/stdlib/fcvt.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/stdlib/fcvt.c b/src/stdlib/fcvt.c
index 003aa5aa..f90928fe 100644
--- a/src/stdlib/fcvt.c
+++ b/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;
}