-
Notifications
You must be signed in to change notification settings - Fork 393
Best approach? #273
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
Thanks! Happy to hear you enjoy it. Could you read through it and comment on whether that answers your question or if you still see a use for adding this to the library? I'm all open to it, I just need a good, specific usecase to relate to where adding it brings real value. |
Hi Andreas, Missed that topic. Interesting! You're writing:
I believe there is no real difference between "piece" and "meter" in that aspect, only the way the factor of the unit is used. Consider the following: 1 kilometer = 1000 meter You can actually read a multiplication operator in both. Let us take "1000 meter" for example. You could write this as: 1000 x 1 meter In this example the unit is "1 meter", but what if I would write it like this: 1 x 1000 meter Then "1000 meter" would be the unit. Now because of the SI, we write "1000 meter" like "kilometer", resulting in: 1 x 1 kilometer So the first equation can also be written as: 1 x 1 kilometer = 1000 x 1 meter = 1 x 1000 meter Usually we don't write it like this, because it's awkward, however that is exactly how pieces work. Usually the SI prefices are not used (kilo, deca, etc.), but the way of work is similar: 1000 x 1 piece = 1 x 1000 pieces = 4 x 250 pieces, etc. Where "1 piece", "1000 pieces" and "250 pieces" are actually units. In trade they can be used as sales unit, purchase unit, etc. Curious to hear what you think of this! Cheers, Peter |
Oh, you closed it? I haven't had time to look at this yet. |
Hmmm... Not what i wanted to do, sorry, I dont know how I did this... |
I get what you are saying about The best way this would translate into UnitsNet's current representation, is to add a new quantity https://en.wikipedia.org/wiki/Category:Units_of_amount I don't see a good way to introduce what you are proposing, with M x N pieces, without creating a separate type for this. Something like:
But this does not feel right for a type to belong in UnitsNet. It seems like application-specific code, rather than generic unit representations and conversions. If I have misunderstood or you have a better proposal, please let me know. So what do you think of |
Any more thoughts on this? |
Sorry for the late response! The Amount approach is interesting (never heard of the unit Megadeath before...), but as the units can be indeed specific for the business I think your MxN implementation could work... I will experiment with this and let you know how it works. I might take some time as other projects are taking my attention right know. Thanks so far! Cheers. |
Alright, I'm closing this topic for now then. Please reopen if you want to continue the discussion at some point. |
Hi,
First of all, compliments on your work! Really cool stuff.
I would like to add a "Pieces" unit, where piece is defined as a quantity of something, e.g. 18 pieces of a laptop.
Now the hard part is that 18 pieces should actually be read as 18 x 1 piece, where 1 piece is the unit. But I would also like to be able to say that it's 1 x 18 pieces. This would mean making the factor versus the baseunit a variable.
Is something like this possible with UnitsNet? What would be the best approach for supporting this?
Please let me know if you need more information.
Cheers,
Peter
The text was updated successfully, but these errors were encountered: