Commit 57917c0e authored by jD91mZM2's avatar jD91mZM2

Fix various floating point issues in printf

parent 4621a824
Pipeline #5250 failed with stages
in 7 minutes and 2 seconds
This diff is collapsed.
......@@ -37,6 +37,15 @@ Float madness:
0.000010
-1.234568e+02
-00000001.234568e+02
%.5g: -123.46
%.5f: -123.45679
%.5e: -1.23457e+02
%.*g: -1.2e+02
%.*f: -123.46
%.*e: -1.23e+02
%.*2$g: -123.46
%.*2$f: -123.45679
%.*2$e: -1.23457e+02
100000
1e+06
1.000000e+06
......
......@@ -45,6 +45,15 @@ int main(void) {
printf("%20F\n", 0.00001);
printf("%20e\n", -123.456789123);
printf("%020e\n", -123.456789123);
printf("%%.5g: %.5g\n", -123.456789123);
printf("%%.5f: %.5f\n", -123.456789123);
printf("%%.5e: %.5e\n", -123.456789123);
printf("%%.*g: %.*g\n", 2, -123.456789123);
printf("%%.*f: %.*f\n", 2, -123.456789123);
printf("%%.*e: %.*e\n", 2, -123.456789123);
printf("%%.*2$g: %.*2$g\n", -123.456789123, 5);
printf("%%.*2$f: %.*2$f\n", -123.456789123, 5);
printf("%%.*2$e: %.*2$e\n", -123.456789123, 5);
printf("%g\n", 100000.0);
printf("%g\n", 1000000.0);
......
......@@ -26,6 +26,9 @@ do
echo "# ${name}: ${output}: generated #"
cat "gen/${name}.${output}"
echo "# ${name}: ${output}: diff #"
diff --color -u "expected/${name}.${output}" "gen/${name}.${output}"
status="${status}, ${output} mismatch"
fi
done
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment