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

NumberSystem must support Number types outside the JDK #229

Closed
keilw opened this issue Jun 7, 2019 · 6 comments
Closed

NumberSystem must support Number types outside the JDK #229

keilw opened this issue Jun 7, 2019 · 6 comments
Milestone

Comments

@keilw
Copy link
Member

keilw commented Jun 7, 2019

DefaultNumberSystem currently throws an IllegalArgumentException outside a small selection of Number subtypes, primarily those inside the JDK.

That is not a reasonable behavior, because there are other Number types defined by libraries like Apache Commons Numbers, GNU Math although that even defines Quantity and Unit in a rather weird way (Unit extends Quantity and both extend Numeric which is a Number), but other numeric types like RealNum often go beyond what we define here, so it should not be prevented to use another kind of Number.

@keilw keilw added the bug label Jun 7, 2019
@keilw keilw added this to the 2.0 milestone Jun 7, 2019
@andi-huber
Copy link
Member

Just to clarify: Any implementation of our NumberSystem interface can by design only support a closed set of concrete Number types. If users intend to use different or additional Number types, they also need to provide their own implementation of NumberSystem and configure Indryia to use it (by setting the static Calculus.NUMBER_SYSTEM field).

@andi-huber
Copy link
Member

... this might be inconvenient for some use-cases, but still I'd rather have a reference implementation that does the arithmetic right (and fails early), than using a fallback which might involve precision loss, only to play nice with other libraries.

However, we could provide a second NumberSystem implementation, that does not throw these Exceptions, just to give users the option. But I would not recommend it, because I have a feeling it jeopardizes the purpose of this RI.

@keilw
Copy link
Member Author

keilw commented Jun 7, 2019

Can they do that without further extending e.g. NumberQuantity?

@andi-huber
Copy link
Member

Yes, at least that's the intent.

@keilw
Copy link
Member Author

keilw commented Jun 7, 2019

It seems to do this only via a static member variable in Calculus, I probably would move this to the Indriya SPI similar to DimensionalModel Most people won't have to replace the DimensionalModel, but they could, and at the very least they should also be able to extend the NumberSystem.

@andi-huber
Copy link
Member

Fine with me!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants