Skip to content

Conversation

@nimo23
Copy link
Contributor

@nimo23 nimo23 commented Sep 4, 2023

Fixes #.

Changes proposed in this pull request:

  • added Num.bigDecimalValue() to convert the Num to a BigDecimal

    • For DecimalNum it returns its delegate
    • For DoubleNum it converts by BigDecimal.valueOf(delegate) (if delegate is NaN or Infinity, then it simply returns null)
    • For NaN it simply returns null.
  • added an entry with related ticket number(s) to the unreleased section of CHANGES.md

Actually, it's not easy to get the BigDecimal-representation of a Num. We have intValue(), longValue(), doubleValue(), etc. so it also makes sense to add bigDecimalValue().

@nimo23
Copy link
Contributor Author

nimo23 commented Sep 4, 2023

Would it be better to overwrite bigDecimalValue() in its subclasses instead of providing a default method?

For example, in DecimalNum:

 @Override
 public BigDecimal bigDecimalValue() {
        return delegate;
}

With this, no if and cast is needed..

@TheCookieLab
Copy link
Member

Would it be better to overwrite bigDecimalValue() in its subclasses instead of providing a default method?

For example, in DecimalNum:

 @Override
 public BigDecimal bigDecimalValue() {
        return delegate;
}

With this, no if and cast is needed..

Yes, that would be ideal.

@TheCookieLab TheCookieLab merged commit 7e296de into ta4j:master Jul 6, 2024
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.

2 participants