Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation for Kernel#BigDecimal() digits argument [ci skip] #151

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions ext/bigdecimal/bigdecimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -2681,9 +2681,8 @@ VpNewVarArg(int argc, VALUE *argv)
* If it is a String, spaces are ignored and unrecognized characters
* terminate the value.
*
* digits:: The number of significant digits, as an Integer. If omitted or 0,
* the number of significant digits is determined from the initial
* value.
* digits:: The number of significant digits, as an Integer. This is required if
* +initial+ is a Float or Rational, and ignored otherwise.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

0 for digits has the special meaning that the number of significant digits is automatically determined from the given initial value. For a Rational initial value, for example, the resulting BigDecimal is determined on the value of BigDecimal.limit and the behavior of BigDecimal#div.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. I wonder if there is a better way to word it. I want the documentation to explain that it does not have an effect in cases where you would expect it would:

BigDecimal(1.1234, 2)
# => 0.11e1
BigDecimal(Rational(11234,10000), 2)
# => 0.11e1
BigDecimal('1.1234', 2)
# => 0.11234e1

BigDecimal(11234.0, 2)
# => 0.11e5
BigDecimal(11234, 2)
# => 0.11234e5

*
* The actual number of significant digits used in computation is
* usually larger than the specified number.
Expand Down