With math/big supporting underscores directly, there is no need to
manually remove them before calling the math/big conversion routines.
Updates #28493.
Change-Id: I6f865c8f87c3469ffd6c33f960ed540135055226
Reviewed-on: https://go-review.googlesource.com/c/go/+/166417
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
"fmt"
"math"
"math/big"
- "strings"
)
// implements float arithmetic
}
func (a *Mpflt) SetString(as string) {
- // TODO(gri) remove this code once math/big.Float.Parse can handle separators
- as = strings.Replace(as, "_", "", -1) // strip separators
-
// TODO(gri) why is this needed?
for len(as) > 0 && (as[0] == ' ' || as[0] == '\t') {
as = as[1:]
import (
"fmt"
"math/big"
- "strings"
)
// implements integer arithmetic
}
func (a *Mpint) SetString(as string) {
- // TODO(gri) remove this code once math/big.Int.SetString can handle separators
- as = strings.Replace(as, "_", "", -1) // strip separators
-
_, ok := a.Val.SetString(as, 0)
if !ok {
// required syntax is [+-][0[x]]d*