bigdecimal
bigdecimal copied to clipboard
Incorrect documentation for BigDecimal#sign
The documentation for BigDecimal#sign is incorrect. It reads:
Returns a positive value if > 0, a negative value if < 0, and a zero if == 0.
https://github.com/ruby/bigdecimal/blob/f3e6bfde51375fb873f5ecda897338504743ff13/ext/bigdecimal/bigdecimal.c#L2735-L2736
However, this does not match BigDecimal's behavior:
[1] pry(main)> require 'bigdecimal'
=> true
[2] pry(main)> BigDecimal.new("0").sign
=> 1
[3] pry(main)> BigDecimal.new("-0").sign
=> -1
These values match the BigDecimal::SIGN_XXX constants for signed zeroes, which have the values 1 and -1 (neither of which is zero as #sign seems to document)