-
Notifications
You must be signed in to change notification settings - Fork 26
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
conversion of unit to string #80
Comments
The original conversion is lost, there is no way to store the original string in a very compact data structure. So generally the to string operations convert to the most compact representation. Still some bugs I am sure, but the general requirement was that the string produced needed to be able be converted back into the same unit. A so options would include units::precise_unit samples=generate_custom_count_unit(3);
addUserDefinedUnit("samples",samples); Then it would never get mistaken for a count. and the string would produce addUserDefinedUnit("samples/second", samples/precise::s); Side Note: still need to generate more documentation on generating custom_units and custom_count_units. |
As for As far as counting of specific things I have either used a |
added documentation |
Hi,
Thanks for the nice library. I have been playing with it to convert strings to measurements or units, and so far it works well. When converting back to a string, though, the original representation of the unit is lost. For example, if I define a custom count unit
samples
, then the string "samples/second" is correctly parsed, but converting the resulting unit back to a string results inBq
. What is the recommended way to preserve the original unit representation?Separately, I was wondering if the unit
Hz
should actually be defined as count per second (i.e. counting the number of cycles per second). This would then make it compatible with samples/second (sampling rate) and spikes/second (firing rate of brain cells) that are generally expressed in Hz. Alternatively, I don't definesamples
andspikes
as count units, but then I wonder how I could differentiate after conversion of a string to a measurement between "2" and "2 samples" without parsing the string again myself.-Fabian
The text was updated successfully, but these errors were encountered: