Skip to content

fmt: wrong output for format %g #458

Closed
@gopherbot

Description

@gopherbot

by trukenmueller:

package main
import (
        "fmt"
)
func main() {
        var x float64
        x = 1.0/9.0
        fmt.Printf("%g %f\n",x,x)
}


What is the expected output?
0.111111 0.111111

%g should produce a short form (at least not longer than %f)

What do you see instead?
0.1111111111111111 0.111111

What is your $GOOS?  $GOARCH? linux 386


Which revision are you using?  (hg identify)
84e097972fa7 tip

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions