-
Notifications
You must be signed in to change notification settings - Fork 387
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
Oktas #879
Comments
An Okta is always an integer value? You can't have fraction of an Okta? If that's the case then use the current backing store with a max of 9 and a min of 9 and always round the value at creation. |
But what if someone does an Okta.FromPercent and gets an instance of Okta which is saving an integer okta value, and the developer wants to convert it back to the original percentage value? This is what I mean. |
Hi, how about something like this:
This way it rounds to the nearest Okta integer, while quantity supports values like 35% cloud cover or fractions. |
Brilliant, I have this CloudCover.json so far, not sure what else I need. Some notes:
Committed to https://github.com/MarkCiliaVincenti/UnitsNet/tree/cloudcover for now. |
Fine by me.
They are auto-generated, you just need to fill in the test value for each unit. See
This is a first, but how about wrapping everything in a Alternatively we could throw an exception, but I'm not sure if that currently fits into how the code generator currently inserts these conversion functions into C# code, might require some modifications. |
Looks like you are on the right path though, please create a PR and we can continue the discussion there and have some actual code to look at. |
So I can't use System.Math.Clamp as it's not in netstandard2.0, nor can I use Math.Min(Math.Max()) as the 'x' in Math.Max is replaced with the value, nor is using both Min and Max efficient. Ideally we write our own extension method. Something like this:
|
Also, what should I do to change type? Okta should be in byte or at least int32. |
Ah, right. Yes, an extension would be a good approach then. You can't change the type of the public
public int IntegerOktas => Convert.ToInt32(Oktas);
|
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. |
I want to add oktas to UnitsNet. The problem is that they're usually expressed in integers. What approach do you recommend? I was thinking internally saving a Ratio and then express in octa integers when converted.
https://en.wikipedia.org/wiki/Okta
The text was updated successfully, but these errors were encountered: