Closed mthom closed 8 months ago
Thanks for reporting this! 0
is indeed unsigned. However, it's a common choice for big integer libraries to store the sign as a binary flag and regard zero as positive, for efficiency and clarity. I apologize for not making this super clear, it will be included in the guide I'm going to publish soon.
To fix the issue, you can either add an additional check on zero with .is_zero()
which is super cheap, or use the signum()
method to determine the sign (which seems to fit what you want).
This behavior won't be changed, unfortunately. Therefore, I will close the issue, and feel free to feedback if you meet other related problems.
Looking at the
Sign
variants, there are onlyPositive
andNegative
. In mathematics,0
is neither positive nor negative, so aZero
variant is missing! A bug in Scryer Prolog, whose arithmetics library is dashu, is witness to this: https://github.com/mthom/scryer-prolog/issues/2157