Closed timlg07 closed 3 years ago
A more accurate definition of the format syntax:
"x.y" with x being the number of digits before and y the number of digits after the decimal point. The precision in this case is always fixed and defined as: precision = x + y. This definition overwrites a manually given precision. The exponent will be adjusted to meet the format requirements. If the exponent is zero, it is omitted.
"x." with x being the number of digits before the decimal point. In this case, all operations will be performed with default precision. The number of digits after the floating point is not limited and is used for all actual-precision - x remaining digits. In case no digits are leftover, which happens if and only if actual-precision = x, the floating-point is omitted. The exponent will still be adjusted to meet the requirements of the format.
".y" with y being the number of digits after the decimal point. Analogical to the previous case, the default precision behavior is used; all remaining digits will now be placed before the decimal point and the exponent will get adjusted as necessary. The floating-point won't get omitted in any case though: If actual-precision = y a leading 0 followed by the point will be added.
"." does not limit the amount of digits at all. The default precision behavior will be used and the digits will be split so that the exponent is zero and can be omitted completely. => This is the only format, that will never contain an exponent.
If you add a plus sign +
as first character of the format string, the sign is always shown, even when it might be redundant. This makes it easier for you to process the output, as you can always expect the first character to be the sign (Even if the result is zero).
Notes:
Format parameter parser finished: #32.
0.0
should throw a warning and be ignored.Formatting algorithm implemented: #33
Plus sign option implemented: #34 #36
Basic automated tests written: #37
Possible syntax for output formatting: