Skip to content

Make BigDecimalFromDigits extend FromDigits.Floating #7420

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

Merged
merged 1 commit into from
Oct 15, 2019

Conversation

bishabosha
Copy link
Member

fixes #7419

The given instance in FromDigits for BigDecimal was incorrectly ignoring exponents in number literals.

The given instance in FromDigits for BigDecimal was incorrectly ignoring exponents in number literals,
This commit instead allows exponents in BigDecimal literals, and adds a test.
@bishabosha bishabosha requested a review from smarter October 13, 2019 22:04
@bishabosha bishabosha changed the title Make BigDecimalFromDigits FromDigits.Floating[BigDecimal] Make BigDecimalFromDigits extend FromDigits.Floating Oct 13, 2019
@@ -158,7 +158,7 @@ object FromDigits {
def fromDigits(digits: String, radix: Int): BigInt = BigInt(digits, radix)
}

given BigDecimalFromDigits : FromDigits.Decimal[BigDecimal] {
given BigDecimalFromDigits : FromDigits.Floating[BigDecimal] {
Copy link
Member

Choose a reason for hiding this comment

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

This looks like the correct fix, but then in which case would you actually use FromDigits.Decimal ? It seems like it's not really useful on its own /cc @odersky

Copy link
Member Author

@bishabosha bishabosha Oct 14, 2019

Choose a reason for hiding this comment

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

I guess if there is no sparse representation for the implementation then it could make sense, but it's simple to convert from an exponent anyway.

@bishabosha bishabosha merged commit 174de92 into scala:master Oct 15, 2019
@bishabosha bishabosha deleted the bigdec_fromFloating branch October 15, 2019 15:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

BigDecimalFromDigits unused for generic literals with exponents
2 participants