mirror of
https://github.com/shopspring/decimal.git
synced 2024-11-22 12:30:49 +01:00
add functions IsPositive, IsNegative and IsZero (#88)
This commit is contained in:
parent
2df3e6ddaf
commit
19e3cb6c29
1 changed files with 27 additions and 0 deletions
27
decimal.go
27
decimal.go
|
@ -556,6 +556,33 @@ func (d Decimal) Sign() int {
|
|||
return d.value.Sign()
|
||||
}
|
||||
|
||||
// IsPositive return
|
||||
//
|
||||
// true if d > 0
|
||||
// false if d == 0
|
||||
// false if d < 0
|
||||
func (d Decimal) IsPositive() bool {
|
||||
return d.Sign() == 1
|
||||
}
|
||||
|
||||
// IsNegative return
|
||||
//
|
||||
// true if d < 0
|
||||
// false if d == 0
|
||||
// false if d > 0
|
||||
func (d Decimal) IsNegative() bool {
|
||||
return d.Sign() == -1
|
||||
}
|
||||
|
||||
// IsZero return
|
||||
//
|
||||
// true if d == 0
|
||||
// false if d > 0
|
||||
// false if d < 0
|
||||
func (d Decimal) IsZero() bool {
|
||||
return d.Sign() == 0
|
||||
}
|
||||
|
||||
// Exponent returns the exponent, or scale component of the decimal.
|
||||
func (d Decimal) Exponent() int32 {
|
||||
return d.exp
|
||||
|
|
Loading…
Reference in a new issue