ericlagergren / decimal

A high-performance, arbitrary-precision, floating-point decimal library.
https://godoc.org/github.com/ericlagergren/decimal
BSD 3-Clause "New" or "Revised" License
518 stars 61 forks source link

Make isZero public. #157

Closed jordanlewis closed 2 years ago

jordanlewis commented 3 years ago

IsZero is a very handy method. It's often convenient to know whether a decimal is zero or not. Make it public for outside use.

ericlagergren commented 3 years ago

The correct way of checking whether a decimal is zero is comparing Sign with zero as it handles the case where the decimal is an infinity or NaN. isZero doesn’t perform those checks.

I am not necessarily opposed to adding func (x *Big) IsZero() bool { return x.Sign() == 0 }.

ericlagergren commented 2 years ago

since there are conflicts, i'm going to close this for now. But if you feel strongly about IsZero vs Sign then I'll be glad to re-open it.