Improve rounding when converting between mg/dL and mmol/L #377
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Addresses Issue #267
Currently, Trio just rounds down when logging a manual glucose entry in mmol/L. This means that 7.6 gets logged as 7.5 because 7.6 / 0.0555 ≈ 136.9 gets rounded to 136 when
Int(glucose)
is performed which gets displayed as 7.5 because 136 * 0.0555 ≈ 7.5.This PR rounds
asMgdL
to 0 decimal places andasMmolL
to 1 decimal place which allows for more accurate rounding when converting units and back.Here's a spreadsheet that highlights the mmol/L readings that caused mismatches: https://docs.google.com/spreadsheets/d/10ZHV7ZDd0_fjrV6k0FH1ouuqy2TSsDSBpBULE4yAFyg/edit?usp=sharing