Skip to content

Commit

Permalink
Update types/uint.go
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderbez authored and Alessio Treglia committed Feb 19, 2019
1 parent 8d73754 commit a5092ea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
5 changes: 0 additions & 5 deletions types/int.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,11 +318,6 @@ func (i Int) String() string {
return i.i.String()
}

// Testing purpose random Int generator
func randomInt(i Int) Int {
return NewIntFromBigInt(random(i.BigInt()))
}

// MarshalAmino defines custom encoding scheme
func (i Int) MarshalAmino() (string, error) {
if i.i == nil { // Necessary since default Uint initialization has i.i as nil
Expand Down
17 changes: 8 additions & 9 deletions types/uint.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
package types

import (
"errors"
"fmt"
"math/big"

"github.com/pkg/errors"
)

// Unt wraps integer with 256 bit range bound
// Uint wraps integer with 256 bit range bound
// Checks overflow, underflow and division by zero
// Exists in range from 0 to 2^256-1
type Uint struct {
Expand Down Expand Up @@ -40,10 +39,10 @@ func NewUintFromString(s string) Uint {
}

// ZeroUint returns unsigned zero.
func ZeroUint() Uint { return NewUint(0) }
func ZeroUint() Uint { return Uint{big.NewInt(0)} }

// OneUint returns Uint value with one
func OneUint() Uint { return NewUint(1) }
// OneUint returns Uint value with one.
func OneUint() Uint { return Uint{big.NewInt(1)} }

// Uint64 converts Uint to uint64
// Panics if the value is out of range
Expand Down Expand Up @@ -81,15 +80,15 @@ func (u Uint) AddUint64(u2 uint64) Uint { return u.Add(NewUint(u2)) }
// Add adds Uint from another
func (u Uint) Sub(u2 Uint) Uint { return NewUintFromBigInt(new(big.Int).Sub(u.i, u2.i)) }

// Add adds Uint from another
// SubUint64 adds Uint from another
func (u Uint) SubUint64(u2 uint64) Uint { return u.Sub(NewUint(u2)) }

// Mul multiples two Uints
// Mul multiplies two Uints
func (u Uint) Mul(u2 Uint) (res Uint) {
return NewUintFromBigInt(new(big.Int).Mul(u.i, u2.i))
}

// Mul multiples two Uints
// Mul multiplies two Uints
func (u Uint) MulUint64(u2 uint64) (res Uint) { return u.Mul(NewUint(u2)) }

// Div divides Uint with Uint
Expand Down

0 comments on commit a5092ea

Please sign in to comment.