mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 23:02:27 +00:00
VM: Add Sub, Mul, Mod LSH, RSH
This commit is contained in:
parent
c163ae2019
commit
64491a4d83
2 changed files with 92 additions and 0 deletions
|
@ -27,11 +27,46 @@ func (i *Int) Equal(s *Int) bool {
|
|||
|
||||
// Add will add two stackIntegers together
|
||||
func (i *Int) Add(s *Int) (*Int, error) {
|
||||
return &Int{
|
||||
val: new(big.Int).Add(i.val, s.val),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Sub will subtract two stackIntegers together
|
||||
func (i *Int) Sub(s *Int) (*Int, error) {
|
||||
return &Int{
|
||||
val: new(big.Int).Sub(i.val, s.val),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Mul will multiply two stackIntegers together
|
||||
func (i *Int) Mul(s *Int) (*Int, error) {
|
||||
return &Int{
|
||||
val: new(big.Int).Mul(i.val, s.val),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Mod will take the mod of two stackIntegers together
|
||||
func (i *Int) Mod(s *Int) (*Int, error) {
|
||||
return &Int{
|
||||
val: new(big.Int).Mod(i.val, s.val),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Rsh will shift the integer b to the right by `n` bits
|
||||
func (i *Int) Rsh(n *Int) (*Int, error) {
|
||||
return &Int{
|
||||
val: new(big.Int).Rsh(i.val, uint(n.val.Int64())),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Lsh will shift the integer b to the left by `n` bits
|
||||
func (i *Int) Lsh(n *Int) (*Int, error) {
|
||||
return &Int{
|
||||
val: new(big.Int).Lsh(i.val, uint(n.val.Int64())),
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Integer will overwrite the default implementation
|
||||
// to allow go to cast this item as an integer.
|
||||
func (i *Int) Integer() (*Int, error) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue