as = as[1:]
}
- // Currently, Val.Parse below (== math/big.Float.Parse) does not
- // handle the 0o-octal prefix which can appear with octal integers
- // with 'i' suffix, which end up here as imaginary components of
- // complex numbers. Handle explicitly for now.
- // TODO(gri) remove once Float.Parse can handle octals (it handles 0b/0B)
- var f *big.Float
- if strings.HasPrefix(as, "0o") || strings.HasPrefix(as, "0O") {
- x, ok := new(big.Int).SetString(as[2:], 8)
- if !ok {
- yyerror("malformed constant: %s", as)
- a.Val.SetFloat64(0)
- return
- }
- f = a.Val.SetInt(x)
- } else {
- var err error
- f, _, err = a.Val.Parse(as, 0)
- if err != nil {
- yyerror("malformed constant: %s (%v)", as, err)
- a.Val.SetFloat64(0)
- return
- }
+ f, _, err := a.Val.Parse(as, 0)
+ if err != nil {
+ yyerror("malformed constant: %s (%v)", as, err)
+ a.Val.SetFloat64(0)
+ return
}
if f.IsInf() {
}
func (a *Mpint) SetString(as string) {
- // TODO(gri) remove this code once math/big.Int.SetString can handle 0o-octals and separators
+ // TODO(gri) remove this code once math/big.Int.SetString can handle separators
as = strings.Replace(as, "_", "", -1) // strip separators
- if len(as) >= 2 && as[0] == '0' && (as[1] == 'o' || as[1] == 'O') {
- as = "0" + as[2:]
- }
_, ok := a.Val.SetString(as, 0)
if !ok {