Skip to content

math/big: underflow panic in roundShortest #20867

@bcmills

Description

@bcmills
	f := new(big.Float).SetPrec(big.MaxPrec).SetFloat64(1)

	b := f.Append(nil, 'g', -1)

panics with the following stack trace:

panic: underflow

goroutine 1 [running]:
math/big.nat.sub(0x0, 0x0, 0x0, 0x104402c0, 0x0, 0x6, 0x180010, 0x1, 0x1, 0x0, ...)
	/usr/local/go/src/math/big/nat.go:129 +0x3e0
math/big.roundShortest(0x10429f38, 0x10429f90)
	/usr/local/go/src/math/big/ftoa.go:195 +0x1c0
math/big.(*Float).Append(0x10429f90, 0x0, 0x0, 0x0, 0x10429f67, 0xffffffff, 0x104340b0, 0x371f, 0x0, 0x1040a130)
	/usr/local/go/src/math/big/ftoa.go:97 +0x680
main.main()
	/tmp/sandbox082194187/main.go:11 +0xc0

(https://play.golang.org/p/68rBsop-pW)

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsFixThe path to resolution is known, but the work has not been done.help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions