You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
%g in Go is different from %g in C.
%g in Go means print as many digits as are necessary
for strconv.Atof64 or strconv.Atof32 (depending on
the type being printed) to reconstruct exactly the
same value.
To limit the number of digits (and give up this property)
use a size modifier as in %6g.
by trukenmueller:
The text was updated successfully, but these errors were encountered: