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
What steps will reproduce the problem?
fmt.Fscanf appears to produce incorrect results when a newline is
preceded by a space.
package main
import "fmt"
import "strings"
func main() {
var z float64
fmt.Printf("unexpected result\n")
in := strings.NewReader(" 1.1 1.2 1.3 \n 2.4 2.5 2.6 \n 3.7 3.8 3.9 ")
for i := 0; i < 9; i++ {
fmt.Fscanf(in, "%e", &z) // throws "unexpected newline"
fmt.Printf(" %g ", z)
}
fmt.Printf("\n")
fmt.Printf("expected result\n")
in = strings.NewReader(" 1.1 1.2 1.3\n 2.4 2.5 2.6\n 3.7 3.8 3.9")
for i := 0; i < 9; i++ {
fmt.Fscanf(in, "%e", &z)
fmt.Printf(" %g ", z)
}
fmt.Printf("\n")
}
What is the expected output?
expected result
1.1 1.2 1.3 2.4 2.5 2.6 3.7 3.8 3.9
What do you see instead?
unexpected result
1.1 1.2 1.3 1.3 2.4 2.5 2.6 2.6 3.7
What is your $GOOS? $GOARCH?
GOARCH=amd64
GOOS=darwin
Which revision are you using? (hg identify)
localhost:go $ hg summary
parent: 5812:5992bf56aa72 release.2010-07-14 release
release.2010-07-14
branch: default
commit: 1 unknown (clean)
update: 54 new changesets (update)
Please provide any additional information below.
The text was updated successfully, but these errors were encountered:
by bcfabien:
The text was updated successfully, but these errors were encountered: