Re: [go-nuts] Re: Unexpected behavior of %+02d in Sprintf() and friends

2018-08-29 Thread Eric Raymond
On Wednesday, August 29, 2018 at 7:57:23 AM UTC-4, Borman, Paul wrote: > > Is it possible you used the format string “+%02d” vs “%+02d”? The first > will give you the +00 you expected while the second is +0, as discussed. > Alas, no. Here's the line from my test program: fmt.Printf("%s: %+02d

Re: [go-nuts] Re: Unexpected behavior of %+02d in Sprintf() and friends

2018-08-29 Thread 'Borman, Paul' via golang-nuts
Is it possible you used the format string “+%02d” vs “%+02d”? The first will give you the +00 you expected while the second is +0, as discussed. On Aug 29, 2018, at 6:53 AM, Eric Raymond mailto:e...@thyrsus.com>> wrote: On Tuesday, August 28, 2018 at 4:49:02 PM UTC-4, peterGo wrote: "Width is

[go-nuts] Re: Unexpected behavior of %+02d in Sprintf() and friends

2018-08-29 Thread Eric Raymond
On Tuesday, August 28, 2018 at 4:49:02 PM UTC-4, peterGo wrote: > > "Width is specified by an optional decimal number immediately preceding > the verb. If absent, the width is whatever is necessary to represent the > value. " > > https://golang.org/pkg/fmt/ > > Width is two. > Thanks for the cla

[go-nuts] Re: Unexpected behavior of %+02d in Sprintf() and friends

2018-08-28 Thread peterGo
Eric, For example, package main import ( "fmt" "runtime" ) func main() { // Correctly prints "+0 00\n" as +00 00 fmt.Printf("%s: %+03d %02d\n", runtime.Version(), 0, 0) } Output: go1.10.3: +00 00 Playground: https://play.golang.org/p/Pt2-YJfQvEo Widths three and two. Peter

[go-nuts] Re: Unexpected behavior of %+02d in Sprintf() and friends

2018-08-28 Thread peterGo
Eric, "Width is specified by an optional decimal number immediately preceding the verb. If absent, the width is whatever is necessary to represent the value. " https://golang.org/pkg/fmt/ Width is two. Peter On Tuesday, August 28, 2018 at 12:09:26 PM UTC-4, Eric Raymond wrote: > > Under Go 1