Skip to content

Allow infinity to be a valid number #998

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

Closed
tmilnthorp opened this issue Dec 1, 2021 · 9 comments
Closed

Allow infinity to be a valid number #998

tmilnthorp opened this issue Dec 1, 2021 · 9 comments

Comments

@tmilnthorp
Copy link
Collaborator

Is your feature request related to a problem? Please describe.
We would like to be able to indicate things such as perfect conductivity or perfectly insulated objects. This requires double.PositiveInfinity to be accepted to unit constructors.

Describe the solution you'd like
Remove the guard check for infinity.

Describe alternatives you've considered
We have considered using double.MaxValue (which is our interim solution), however it is more accurate to use infinity.

Note this is a breaking behavior change. Should this be only considered for v5?

@tmilnthorp tmilnthorp added this to the 5.0 milestone Dec 1, 2021
@tmilnthorp
Copy link
Collaborator Author

Looking for comments before I touch any code.

@angularsen
Copy link
Owner

I think the main argument for not supporting NaN and Infinity, is that decimal does not support it.
So it would be inconsistent across different quantities.

@tmilnthorp
Copy link
Collaborator Author

I would counter that as completely different underlying types, forcing them into consistent behavior is overly constrictive. Much like some of the arguments for equality, programmers know the underlying type and expect to use them.

I would recommend splitting the guard class into a double and decimal version.

@angularsen
Copy link
Owner

angularsen commented Feb 13, 2022

I see your point, but I do think that very few consumers of UnitsNet know anything about the whole double vs decimal dilemma we are currently at. So I do think it would catch some people off guard.

In #982 , I would like to revisit the quantities using decimal, whether they can be changed to double.
A lot of the precision problems went away 1-2 years ago when we introuced Unit as part of the representation, and for units that are particularly large/smal we can consider adding direct conversion functions to some of the other units to maybe overcome the issue.

@angularsen
Copy link
Owner

If we can get all quantities onto double, then I would be more onboard with supporting NaN and Infinity.

I just think it is not a good experience if some quantities happily accept NaN and others throw an exception, for no intuitive reason.

@stale
Copy link

stale bot commented Apr 16, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Apr 16, 2022
@seanspicer
Copy link

Support for NaN and infinity is of significant interest. Its a major headache in our use of unitsnet.

@stale stale bot removed the wontfix label Apr 21, 2022
@angularsen
Copy link
Owner

I think it might be more natural to support NaN and Infinity after this is merged: #1074

This way, double and decimal will correctly be used on the public properties instead of forcing double everywhere.

@stale
Copy link

stale bot commented Aug 13, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 13, 2022
@stale stale bot closed this as completed Sep 21, 2022
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

3 participants