forked from jocull/rust-measurements
-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
'pick_appropriate_units()': precision versus prettiness #24
Comments
I agree. Please do send a PR. |
Sorry for the radio silence. I had noticed some values still printed strangely, but was distracted by other work. I'll take some time to look into it later this week and make a PR. |
Was this ever fixed? |
I never followed up on my "threat", unfortunately! Anyone else is welcome to beat me to making the PR; I think my branch has a working solution, so I can submit a PR later today too. |
PR has been submitted! |
eldruin
pushed a commit
that referenced
this issue
Jan 12, 2021
Change strict inequality to inequality for the inner loop of pick_appropriate_units, so that if a value is set to 1.0, then the unit returned follows a user's expectation. Closes #24.
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
I noticed recently that, due to the strict bounds checking in
pick_appropriate_units()
insrc/measurement.rs
, that the following code was not producing the output I was expecting:prints the following:
whereas I had expected it to print:
I figure the former is perhaps more precise, but seemed a bit ugly for display when dealing with units which didn't need that precision, particularly given that if I change
val
to be1.00000000001
, I get the output I was expecting (due to precision formatting).I've gone and updated my branch to use the latter by changing
value > 1.0 || value < -1.0
tovalue >= 1.0 || value <= -1.0
inpick_appropriate_units()
. If this is something that is generally more useful, or something to offer as an opt-in, I'd be happy to submit a PR.The text was updated successfully, but these errors were encountered: