mirror of
https://github.com/shopspring/decimal.git
synced 2024-11-22 12:30:49 +01:00
Create zero.go
Zero.go defines convenience functions for testing decimal values with the zero value. These functions make code using decimal easier to read in my opinion. EqualZero() could be renamed into IsZero()
This commit is contained in:
parent
cd690d0c9e
commit
e20cd0e503
1 changed files with 31 additions and 0 deletions
31
zero.go
Normal file
31
zero.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package decimal
|
||||
|
||||
// EqualZero returns whether the numbers represented by d equals zero.
|
||||
func (d Decimal) EqualZero() bool {
|
||||
return d.Equal(Zero)
|
||||
}
|
||||
|
||||
// NotZero returns whether d is not zero
|
||||
func (d Decimal) NotZero() bool {
|
||||
return !d.EqualZero()
|
||||
}
|
||||
|
||||
// GreaterThanZero (GT0) returns true when d is greater than zero.
|
||||
func (d Decimal) GreaterThanZero() bool {
|
||||
return d.GreaterThan(Zero)
|
||||
}
|
||||
|
||||
// GreaterThanOrEqualZero (GTE0) returns true when d is greater than or equal to zero.
|
||||
func (d Decimal) GreaterThanOrEqualZero() bool {
|
||||
return d.GreaterThanOrEqual(Zero)
|
||||
}
|
||||
|
||||
// LessThanZero returns true when d is less than zero.
|
||||
func (d Decimal) LessThanZero() bool {
|
||||
return d.LessThan(Zero)
|
||||
}
|
||||
|
||||
// LessThanOrEqualZero returns true when d is less than or equal to zero.
|
||||
func (d Decimal) LessThanOrEqualZero() bool {
|
||||
return d.LessThanOrEqual(Zero)
|
||||
}
|
Loading…
Reference in a new issue