I have this string formatting command:
format "%#9i" 123
With Tcl 8 I get " 123"
With Tcl 9 I get " 0d123"
The usage of the "#" flag comes from a more general procedure, that
makes sure, that in case of "e" format (scientific notation) there is
always a decimal point available.
In Tcl 8 "#" had no effect on "i" format.
In Tcl 9 it add "0d" to the result.
Is this a bug or intention?
* meshparts <[email protected]>Thanks.
| I have this string formatting command:
| format "%#9i" 123
| With Tcl 8 I get " 123"
| With Tcl 9 I get " 0d123"
| The usage of the "#" flag comes from a more general procedure, that
| makes sure, that in case of "e" format (scientific notation) there is
| always a decimal point available.
| In Tcl 8 "#" had no effect on "i" format.
| In Tcl 9 it add "0d" to the result.
| Is this a bug or intention?
https://www.tcl-lang.org/man/tcl9.1/TclCmd/format.html#M12
#
Requests an alternate output form. For o conversions, 0o will be
added to the beginning of the result unless it is zero. For x or X
conversions, 0x will be added to the beginning of the result unless
it is zero. For b conversions, 0b will be added to the beginning of
the result unless it is zero.
!! For d conversions, 0d there is no effect unless the 0 specifier is
used as well: In that case, 0d will be added to the beginning.
[...]
The sentence for the 'd' conversion does not really make sense 100% to me (non-english speaker), but it sounds as if "%#9i" should *not* produce
the 0d, since the '0 specifier' is not present.
HTH
R'
* meshparts <[email protected]>
| I have this string formatting command:
| format "%#9i" 123
| With Tcl 8 I get " 123"
| With Tcl 9 I get " 0d123"
| The usage of the "#" flag comes from a more general procedure, that
| makes sure, that in case of "e" format (scientific notation) there is
| always a decimal point available.
| In Tcl 8 "#" had no effect on "i" format.
| In Tcl 9 it add "0d" to the result.
| Is this a bug or intention?
https://www.tcl-lang.org/man/tcl9.1/TclCmd/format.html#M12
#
Requests an alternate output form. For o conversions, 0o will be
added to the beginning of the result unless it is zero. For x or X
conversions, 0x will be added to the beginning of the result unless
it is zero. For b conversions, 0b will be added to the beginning of
the result unless it is zero.
!! For d conversions, 0d there is no effect unless the 0 specifier is
used as well: In that case, 0d will be added to the beginning.
[...]
The sentence for the 'd' conversion does not really make sense 100% to me (non-english speaker), but it sounds as if "%#9i" should *not* produce
the 0d, since the '0 specifier' is not present.
HTH
R'
I suggest replacing:
For d conversions, 0d there is no effect unless the 0 specifier is used
as well: In that case, 0d will be added to the beginning.
with:
For d conversions, 0d has no effect; whereas both #d and #0d produce an
0d prefix.
Might also be worth adding:
Note that width includes any prefix. For example "%06d" shows
at least 6 digits, but "%#06d" shows at least 4 digits.
Evidence:
Main console display active (Tcl9.0.2 / Tk9.0.2)
(mark) 61 % format "%d %0d %06d %#d %#0d %#06d" 12 13 14 15 16 17
12 13 000014 0d15 0d16 0d0017
Sysop: | DaiTengu |
---|---|
Location: | Appleton, WI |
Users: | 1,071 |
Nodes: | 10 (0 / 10) |
Uptime: | 66:21:20 |
Calls: | 13,754 |
Calls today: | 1 |
Files: | 186,984 |
D/L today: |
9,216 files (2,674M bytes) |
Messages: | 2,425,603 |