Commit 2727abe4 authored by Robert Griesemer's avatar Robert Griesemer

- lowercased package name (Bignum -> bignum)

- implemented some missing functionality (and, or, xor of positive ints)

R=r
OCL=19087
CL=19087
parent 9c9cc2c9
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style // Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file. // license that can be found in the LICENSE file.
package Bignum package bignum
// A package for arbitrary precision arithmethic. // A package for arbitrary precision arithmethic.
// It implements the following numeric types: // It implements the following numeric types:
...@@ -1076,27 +1076,42 @@ func (x *Integer) Shl(s uint) *Integer { ...@@ -1076,27 +1076,42 @@ func (x *Integer) Shl(s uint) *Integer {
func (x *Integer) Shr(s uint) *Integer { func (x *Integer) Shr(s uint) *Integer {
z := MakeInt(x.sign, x.mant.Shr(s)); z := MakeInt(x.sign, x.mant.Shr(s));
if x.IsNeg() { if x.IsNeg() {
panic("UNIMPLEMENTED"); panic("UNIMPLEMENTED Integer.Shr() of negative values");
} }
return z; return z;
} }
func (x *Integer) And(y *Integer) *Integer { func (x *Integer) And(y *Integer) *Integer {
panic("UNIMPLEMENTED"); var z *Integer;
return nil; if !x.sign && !y.sign {
z = MakeInt(false, x.mant.And(y.mant));
} else {
panic("UNIMPLEMENTED Integer.And() of negative values");
}
return z;
} }
func (x *Integer) Or(y *Integer) *Integer { func (x *Integer) Or(y *Integer) *Integer {
panic("UNIMPLEMENTED"); var z *Integer;
return nil; if !x.sign && !y.sign {
z = MakeInt(false, x.mant.Or(y.mant));
} else {
panic("UNIMPLEMENTED Integer.Or() of negative values");
}
return z;
} }
func (x *Integer) Xor(y *Integer) *Integer { func (x *Integer) Xor(y *Integer) *Integer {
panic("UNIMPLEMENTED"); var z *Integer;
return nil; if !x.sign && !y.sign {
z = MakeInt(false, x.mant.Xor(y.mant));
} else {
panic("UNIMPLEMENTED Integer.Xor() of negative values");
}
return z;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment