You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I am trying to make a new quantity called RelativeDensity inheriting from IQuantity, but I need the underlying value to be full 128-bit decimal for precision reasons. From this pull request - #1084 - I was under the impression that QuantityValue, not double, was returned by types in UnitsNet.
Describe alternatives you've considered
I could try just submitting a pull request with a RelativeDensity quantity, since it just uses the same units as Density - but I have other quantities to add as well.
The text was updated successfully, but these errors were encountered:
Are you not able to use decimal in RelativeDensity?
You can implement IValueQuantity<decimal> to expose decimal output values, similar to how Power, BitRate and Information does and use decimal as your internal value representation.
However, you also need to implement IQuantity, and any code working with IQuantity instead of IValueQuantity<decimal> gets either
QuantityValue wrapping whatever internal value the quantity uses (typically double)
Or it gets double from methods like As(Enum unit).
I know it is confusing, but generally we use double. Only the 3 mentioned quantities use decimal.
Also, custom units is kind of experimental and has a lot of rough edges like this.
Yes, currently not possible to change numeric type of existing quantities, only custom quantities.
We have discussed supporting generics many times before, but I don't see that moving forward anytime soon, so if you need decimal your best option is to fork and build your own version of UnitsNet at this time.
Is your feature request related to a problem? Please describe.
I am trying to make a new quantity called RelativeDensity inheriting from IQuantity, but I need the underlying value to be full 128-bit decimal for precision reasons. From this pull request - #1084 - I was under the impression that QuantityValue, not double, was returned by types in UnitsNet.
Describe the solution you'd like
Add support for generic or just decimal custom quantities, and update the documentation - https://github.com/angularsen/UnitsNet/wiki/Extending-with-Custom-Units
Describe alternatives you've considered
I could try just submitting a pull request with a RelativeDensity quantity, since it just uses the same units as Density - but I have other quantities to add as well.
The text was updated successfully, but these errors were encountered: