Source File
number.go
Belonging Package
github.com/pancsta/d2/lib/svg
package svgimport ()// FormatFloat serializes an SVG coordinate with the same six decimal places// as %f, but omits redundant trailing zeros. Keeping the original rounding is// important: formatting the full float or reducing precision changes geometry.func ( float64) string {// Most laid-out coordinates are integers. Avoid allocating and formatting// a fractional part only to remove it again. The upper bound is exclusive// because float64(math.MaxInt64) rounds up to 2^63.if >= -0x1p63 && < 0x1p63 {:= int64()if == float64() {if == 0 && math.Signbit() {return "-0"}return strconv.FormatInt(, 10)}}:= strconv.FormatFloat(, 'f', 6, 64)if strings.Contains(, ".") {= strings.TrimRight(, "0")= strings.TrimSuffix(, ".")}return}
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |