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.
| Mix | Test amount | Concentration | Volume | Units |
|---|---|---|---|---|
| 5 mg in 2 mL | 250 mcg | 2.5 mg/mL | 0.1 mL | 10 |
| 10 mg in 2 mL | 2.5 mg | 5 mg/mL | 0.5 mL | 50 |
| 15 mg in 2 mL | 2.5 mg | 7.5 mg/mL | 0.333 mL | 33.3 |
| 10 mg in 1 mL | 500 mcg | 10 mg/mL | 0.05 mL | 5 |