Skip to content

Commit

Permalink
Fix MMOLL_TO_MGDL conversion constant.
Browse files Browse the repository at this point in the history
The molecular weight of glucose is 180.156 g/mol, so (glucose mmol/l) / (glucose mg/dl) = 180.156g * dl/l = 18.0156, rather than 18.0182.

Note: xDrip+ is not the only Diabetes-related software that has the (as far as I can tell) wrong constant. Several other software packages also have the value 18.0182 that I believe to be incorrect, while others have 18.0156 (correct); I suspect that someone got it wrong at some point and the others just copied from them. Dexcom's G6 app uses the value 18.0 in at least one place, which is even further off.

While this seems like an unnecessary place to introduce error, the value was less than 0.15% off the correct value. Rounding to whole mg/dl or to 1/10th of a mmol/l introduces a slightly larger error than this, so if one rounds both before and after the conversion then in practice, the result is unaffected by the exact value of the constant.
  • Loading branch information
15characterlimi committed May 23, 2021
1 parent 3df0152 commit bfd3afd
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Various constants
*/
public class Constants {
public static final double MMOLL_TO_MGDL = 18.0182;
public static final double MMOLL_TO_MGDL = 18.0156;
public static final double MGDL_TO_MMOLL = 1 / MMOLL_TO_MGDL;


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Various constants
*/
public class Constants {
public static final double MMOLL_TO_MGDL = 18.0182;
public static final double MMOLL_TO_MGDL = 18.0156;
public static final double MGDL_TO_MMOLL = 1 / MMOLL_TO_MGDL;


Expand Down

0 comments on commit bfd3afd

Please sign in to comment.