return -1
}
-func (a *Mpint) Add(b *Mpint, quiet int) {
+func (a *Mpint) Add(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
Yyerror("ovf in mpaddfixfix")
a.Val.Add(&a.Val, &b.Val)
- if a.checkOverflow(0) && quiet == 0 {
+ if a.checkOverflow(0) {
Yyerror("constant addition overflow")
}
}
a.Val.Xor(&a.Val, &b.Val)
}
-// shift left by s (or right by -s)
-func (a *Mpint) shift(s int) {
- switch {
- case s > 0:
- if a.checkOverflow(s) {
- Yyerror("constant shift overflow")
- return
- }
- a.Val.Lsh(&a.Val, uint(s))
- case s < 0:
- a.Val.Rsh(&a.Val, uint(-s))
- }
-}
-
func (a *Mpint) Lsh(b *Mpint) {
if a.Ovf || b.Ovf {
if nsavederrors+nerrors == 0 {
return
}
- a.shift(int(s))
+ if a.checkOverflow(int(s)) {
+ Yyerror("constant shift overflow")
+ return
+ }
+ a.Val.Lsh(&a.Val, uint(s))
}
func (a *Mpint) Rsh(b *Mpint) {
return
}
- a.shift(int(-s))
+ a.Val.Rsh(&a.Val, uint(s))
}
func (a *Mpint) Cmp(b *Mpint) int {
if s2.Val().Ctype() == CTRUNE && s4.Val().Ctype() == CTINT {
ss := s2
- s2.Val().U.(*Mpint).Add(s4.Val().U.(*Mpint), 0)
+ s2.Val().U.(*Mpint).Add(s4.Val().U.(*Mpint))
return ss
}
s4.Val().U.(*Mpcplx).Real = s4.Val().U.(*Mpcplx).Imag