-
Notifications
You must be signed in to change notification settings - Fork 18.7k
Closed
Labels
Milestone
Description
$ gotip version
go version devel +a93a124 Tue May 31 15:33:01 2016 +0200 linux/amd64
The documentation of the (x *Float) Text(format byte, prec int) string function says
A negative precision selects the smallest number of decimal digits necessary to identify the value x uniquely.
This is true for -11 < prec < 0, but for prec < -10 the function panics instead:
package main
import (
"fmt"
"math/big"
)
func main() {
z := new(big.Float).SetRat(big.NewRat(1, 3))
fmt.Println(z.Text('f', -11))
}
panic: runtime error: makeslice: cap out of range
goroutine 1 [running]:
panic(0x1886a0, 0x1040a138)
/usr/local/go/src/runtime/panic.go:481 +0x700
math/big.(*Float).Text(0x10427f70, 0x10430266, 0xfffffff5, 0x0, 0x0, 0x0)
/usr/local/go/src/math/big/ftoa.go:45 +0x60
main.main()
/tmp/sandbox979738453/main.go:10 +0xa0