Update documentation for Kernel#BigDecimal() digits argument [ci skip]#151
Open
jeremyevans wants to merge 1 commit intoruby:masterfrom
Open
Update documentation for Kernel#BigDecimal() digits argument [ci skip]#151jeremyevans wants to merge 1 commit intoruby:masterfrom
jeremyevans wants to merge 1 commit intoruby:masterfrom
Conversation
I expected this to affect the significant digits if providing the first argument as a String, but it does not. I'm positive this argument is ignored if the first argument is an Integer, but I'm not positive that it is ignored if the first argument is a String, as the value is passed to VpAlloc. However, if it has an effect, I'm not sure what it is.
mrkn
reviewed
Oct 9, 2019
| * 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. |
Member
There was a problem hiding this comment.
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.
Contributor
Author
There was a problem hiding this comment.
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
I expected this to affect the significant digits if providing
the first argument as a String, but it does not. I'm positive this
argument is ignored if the first argument is an Integer, but I'm
not positive that it is ignored if the first argument is a String,
as the value is passed to VpAlloc. However, if it has an effect,
I'm not sure what it is.