Skip to content

Commit 426fa7a

Browse files
committed
prototyp#BigInt: add IsZeroValue helper method
1 parent 550eed3 commit 426fa7a

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

lib/prototyp/bigint.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,13 @@ func (b BigInt) Int64() int64 {
132132
return bp.Int64()
133133
}
134134

135+
var bigIntZero = big.NewInt(0)
136+
137+
func (b BigInt) IsZeroValue() bool {
138+
bp := (*big.Int)(&b)
139+
return bp.Cmp(bigIntZero) == 0
140+
}
141+
135142
func (b *BigInt) Add(n *big.Int) {
136143
z := b.Int().Add(b.Int(), n)
137144
*b = BigInt(*z)

0 commit comments

Comments
 (0)