Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
fmt: bad formatting of complex numbers with %f #8064
Complex numbers are handled erratically by printf %f verb when using zero padding or space padding. Examples of both are on the playground here: http://play.golang.org/p/9_nUdI3fgd As of today the playground (go1.2rc3) prints the space padding correctly but the zero padding incorrectly. However, on my machine (go1.3beta2 windows/amd64) both the space and zero are incorrect, so there has been a regression with respect to the space padding. My machine output is shown below. Some related CLs: https://golang.org/cl/12498043/ https://golang.org/cl/35660043/ misplaced space-vs-sign issue: (+ 104.66+440.51i) (+ 164.56 -62.29i) ( -75.36+ 186.82i) ( -434.36 -343.48i) ( -403.03 -199.09i) (+ 15.21+313.64i) ( -285.74 -119.34i) ( -181.94 -31.11i) misplaced zero-vs-sign issue: (0-216.970-206.90i) (+0179.08-281.45i) (0-296.810-139.13i) (+0070.67+362.49i) (0-206.890-202.92i) (+0252.57-293.42i) (+0365.34+196.72i) (+0023.82-471.70i)
Rewrite formatFloat to be much simpler and clearer and avoid the tricky interaction with padding. The issue refers to complex but the problem is just floating-point. The new tests added were incorrectly formatted before this fix. Fixes golang#8064. LGTM=jscrockett01, rsc R=rsc, jscrockett01 CC=golang-codereviews https://golang.org/cl/99420048