Skip to content

Commit

Permalink
chore: BigInt's own Cmp() simplifies code in LargerThanComparisons()
Browse files Browse the repository at this point in the history
  • Loading branch information
randomshinichi committed Jun 4, 2019
1 parent 6dccb3c commit 5c356e4
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,19 @@ func (b *BigInt) Validate(formats strfmt.Registry) error {

// LargerThanZero returns true if it is >0
func (b *BigInt) LargerThanZero() bool {
bc := big.Int(*b)
zero := big.Int{}
zero := new(BigInt)

if bc.Cmp(&zero) != 1 {
if b.Cmp(zero) != 1 {
return false
}
return true
}

// LargerOrEqualToZero checks that the number is >=0
func (b *BigInt) LargerOrEqualToZero() bool {
bc := big.Int(*b)
zero := big.Int{}
zero := new(BigInt)

if bc.Cmp(&zero) == -1 {
if b.Cmp(zero) == -1 {
return false
}
return true
Expand Down

0 comments on commit 5c356e4

Please sign in to comment.