-
Notifications
You must be signed in to change notification settings - Fork 393
How to implement fractions of inches #676
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
Comments
Hi, I was on vacation and not able to reply before now.
No, I don't consider this a new unit.
Yes, I think that is a good way to go about it. If you are able to make it generic and reusable, then we could put it into this repo for others to use. If this is for WPF, I believe you can use We also have a sample app in https://github.com/angularsen/UnitsNet/tree/master/Samples/WpfMVVMSample that maybe does something similar to what you want. Did that help answer your questions? |
Please don't apologize for not replying immediately. It's not even been a week! Thank you for taking your time to answer my questions. The formatter has an option for the precision to be used (from full inches only down to x/64th). It might be useable for others as well. I'll see what I can do about cleaning it up and asking for permission to publish it (it was developed as a commision so I do not currently own the copyright). You can go ahead and close this question. |
Great! I'm glad you figured out a solution. |
We have just started using UnitsNet in our applications for the building industry. In the US it is customary to use FeetInches to present lengths of timber, but the resolution of a single inch is too big in many cases, and therefore they are used to presenting the remainder as a fractional part (x/2, y/4, z/16...). An example:
Traditionally I would implement this as a custom formatter where I could specify the max precision (full inches, half, quarter, eighths, sixteenth, 1/32, 1/64 would be the most obvious choices).
However I do not know if this should be thought of as a separate LengthUnit in UnitsNet. I see that there are support for formatters as well, so please guide me as to where this would be a good fit.
Right now I do not need to parse these units, only present them, but there might be others out there who might need to parse this. I assume this might be the fact when for all any units that are using inches (Inch, FeetInches).
Are there any suggestions for how/where this functionality would fit in?
Related issues are:
#579 - Enhanced IFormattable/ToString Support
#585 - Angle (Degrees) to N-S-E-W
Potential gotchas (when implementing):
#673 - Parsing negative FeetInches values
The text was updated successfully, but these errors were encountered: