How the calculator math works

Every calculator on this site uses the four formulas below. They are simple enough to check by hand, and we publish the test cases the code must pass.

Formulas

concentration (mg/mL)   = vial amount (mg) ÷ water added (mL)
draw volume (mL)        = dose (mg) ÷ concentration (mg/mL)
units on U-100 syringe  = draw volume (mL) × 100
doses per vial          = vial amount (mg) ÷ dose (mg)
amount from units (mg)  = units ÷ 100 × concentration (mg/mL)
1 mg = 1,000 mcg

Checks the calculator runs

  • It never fills in or suggests a dose.
  • You must choose mg or mcg. It never assumes a unit.
  • It rejects zero, negative and non-numeric entries.
  • It warns when the result is more than your syringe holds.
  • It warns when the result is under 2 units, which is too small to measure reliably.
  • It warns when the dose is larger than the whole vial, a common sign of an mg and mcg mix-up.
  • Units are rounded to one decimal place. The volume is shown to three.

Test cases

These values are generated by the same code the calculators use, and the automated tests fail if any of them changes.

Test inputs are for checking arithmetic only. They are not dose advice.
MixTest amountConcentrationVolumeUnits
5 mg in 2 mL250 mcg2.5 mg/mL0.1 mL10
10 mg in 2 mL2.5 mg5 mg/mL0.5 mL50
15 mg in 2 mL2.5 mg7.5 mg/mL0.333 mL33.3
10 mg in 1 mL500 mcg10 mg/mL0.05 mL5