Skip to content

math/big: printing a MaxPrec big.Float panics if it was set using a hex format string #49672

@kstenerud

Description

@kstenerud

What version of Go are you using (go version)?

play.golang.org

Does this issue reproduce with the latest release?

Yes

What operating system and processor architecture are you using (go env)?

play.golang.org

What did you do?

https://play.golang.org/p/Ou3piPGDOAF

package main

import (
	"fmt"
	"math/big"
)

func main() {
	flt := &big.Float{}
	flt.SetPrec(big.MaxPrec) // Remove this and it works
	flt.SetString("0x1.5")
	fmt.Printf("%v\n", flt)
}

What did you expect to see?

1.3125

What did you see instead?

%!v(PANIC=Format method: underflow)

Metadata

Metadata

Assignees

No one assigned

    Labels

    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions