Unit conversion
calc_unit_conversion
Converts a value between units of one quantity, between molar and mass units, and between °C and K.
- Runs
- On the server
- Level
- Checked against a reference: exact rational arithmetic
What it is
Converts between units and returns decimal text at result.converted.decimal with its unit. SI scaling and Celsius–kelvin offsets preserve all digits. Conversions between molar and mass units use your formula weight and round to twelve significant figures. A molar result outside the normal range of a double is refused.
Field: Solutions. It is the same calculation as Drybench Calc, called by an AI assistant through the server.
What it does
You give
value(required): Plain decimal text such as '0.0025'. Strings retain all digits and can carry values outside the range of a double. Finite JSON numbers are also accepted.from(required): Unit converted from. Units: kg, g, mg, µg, ng, pg, L, mL, µL, nL, mol, mmol, µmol, nmol, pmol, fmol, M, mM, µM, nM, pM, kg/L, g/L, mg/mL, mg/L, µg/mL, ng/µL, µg/L, ng/mL, kg/mol, kDa, g/mol, Da, cm, mm, m^2, cm^2, mm^2, cells, cells/L, cells/mL, cells/µL, cells/cm^2, cells/mm^2, AU, mAU, degC, K.to(required): Unit converted to, using the same list as from.formulaWeight: Formula weight of the exact chemical form, g/mol; required between molar and mass units.
Asked with
- value
- 2.5
- from
- mg/mL
- to
- mM
- formulaWeight
- 180.2
It answered (computed)
- kind
- molar
Computed by this tool when the page was built. The steps between are not recorded, so this is not a worked example. The reply carries more values than are shown here.
Limits
- Every computed number a reply returns, other than an integer or an exact decimal, is rounded once to 12 significant figures: to the nearest, a change of at most 5 × 10⁻¹² of its value, except that a lower bound is rounded down and an upper bound up, a change of less than 1 × 10⁻¹¹; the method computes, and decides any pass or fail, on the unrounded value.
- No other limit is recorded for this tool.
It will not answer when
- A conversion that needs a density (%, mol/kg, mass to volume).
- Normality (N).
- Activity units (U, IU).
- ppm or ppb.
Every input, with its units4 inputs
value(required): Plain decimal text such as '0.0025'. Strings retain all digits and can carry values outside the range of a double. Finite JSON numbers are also accepted.from(required): Unit converted from. Units: kg, g, mg, µg, ng, pg, L, mL, µL, nL, mol, mmol, µmol, nmol, pmol, fmol, M, mM, µM, nM, pM, kg/L, g/L, mg/mL, mg/L, µg/mL, ng/µL, µg/L, ng/mL, kg/mol, kDa, g/mol, Da, cm, mm, m^2, cm^2, mm^2, cells, cells/L, cells/mL, cells/µL, cells/cm^2, cells/mm^2, AU, mAU, degC, K.to(required): Unit converted to, using the same list as from.formulaWeight: Formula weight of the exact chemical form, g/mol; required between molar and mass units.
Every refusal, with its code15 refusals
| Code | When |
|---|---|
DENSITY | A conversion that needs a density (%, mol/kg, mass to volume). |
NORMALITY | Normality (N). |
ACTIVITY | Activity units (U, IU). |
PPM | ppm or ppb. |
FOLD | A fold change. |
OD | OD600. |
RPM | RPM or × g. |
FORMULA_WEIGHT | A molar bridge needs a positive formula weight. |
INCOMPATIBLE | Units of two different quantities with no bridge. |
UNKNOWN_UNIT | A unit the converter does not list. |
NOT_A_NUMBER | The value is not a plain decimal. |
NEGATIVE | A negative value. |
MAGNITUDE_OUT_OF_RANGE | A nonzero molar bridge result lies outside the normal range of a double. |
BELOW_ABSOLUTE_ZERO | A temperature below 0 K. |
NOT_A_NUMBER | The value is not a plain decimal. |
The calculation
2 methods, each with its equations, constants and worked example.
Equation 1
Within one quantity: value_to = value_from × 10^(exp_from − exp_to), done on the decimal text so no digit is lost
exp is each unit's power of ten to its quantity's base unit (SI prefixes, Table 7
the litre, Table 8).
| Symbol | Meaning |
|---|---|
exp | power of ten from the unit to the base unit (mg: −3 to g), 1 |
Source 1.
Equation 2
Between molar and mass units: mass concentration = molarity × M, mass = amount × M, with M the formula weight the caller states for the exact chemical form.
| Symbol | Meaning |
|---|---|
M | formula weight of the exact form, stated by the caller, g/mol |
| Constant | Value | From |
|---|---|---|
Each listed unit's power of ten to its base unit exp | a table of values, part of the method | Source 1 |
A definition, not a model: the equation states what the quantity means. A different convention gives a different number.
Worked example
Worked example: one case of unit-conversion@1.0.1, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.
Inputs
- value = 150
- from = mM
- to = g/L
- formulaWeight = 58.44
Steps
- prefix: milli = 10⁻³ (SI Table 7) = 0.15 mol/L, from 150 mM = 150 × 10⁻³ mol/L.
- bridge: ρ = c × M = 8.766 g/L, from c = 0.15, M = 58.44; gives result.value.
The working, as the case writes it:
milli = 10⁻³ (Table 7)
mass concentration = molarity × formula weight.
Answer
result.value = 8.766 g/L
Where these values came from: our own exact-arithmetic script and a hand-worked case; BIPM. The International System of Units (SI), 9th edition 2019, V4.01 (June 2026): Table 7 (prefixes), Table 8 (litre, dalton), §2.3.1 (t/°C = T/K − 273.15); the formula weight is the caller's.
The build has not run this example through the tool.
t/°C = T/K − 273.15, exactly, on the decimal text.
| Symbol | Meaning |
|---|---|
t | Celsius temperature, Cel |
T | thermodynamic temperature, K |
Source 1.
| Constant | Value | From |
|---|---|---|
The offset between the scales, exact by definition T0 | 273.15 K | Source 1 |
Kind of method: not recorded.
Worked example
Worked example: one case of temperature-offset@1.0.0, from its inputs through each step to the answer. Values are written as a person writes them; the working carries more digits, so your own figure may differ in the last digit shown.
Inputs
- value = 37
- from = °C
- to = K
Steps
- offset: T/K = t/°C + 273.15 = 310.15 K, from t = 37; gives result.value.
The working, as the case writes it:
T/K = t/°C + 273.15 (SI Brochure §2.3.1).
Answer
result.value = 310.15 K
Where these values came from: our own exact-arithmetic script and a hand-worked case; BIPM. The International System of Units (SI), 9th edition 2019, V4.01 (June 2026): Table 7 (prefixes), Table 8 (litre, dalton), §2.3.1 (t/°C = T/K − 273.15).
The build has not run this example through the tool.
Sources
Bureau International des Poids et Mesures. The International System of Units (SI), 9th edition, 2019 (V4.01, June 2026). doi:10.59161/AUEZ1291.
Used for: Unit conversion within one quantity, with molar bridges through a supplied formula weight; Celsius and kelvin by the exact offset. At: table 7, 8; p. PDF page 19, section 2.3.1, the kelvin.
Read in full, 11 November 2026
How it is checked
- Level
Checked against a reference, the lowest of its 2 methods.
- Checked against
Unit conversion within one quantity, with molar bridges through a supplied formula weight: Exact rational arithmetic (Python 3.13.16 fractions) with factors from the BIPM SI Brochure, 9th edition, on 44 cases, 16 of them refusals: prefix changes exactly as decimal strings, molar bridges to nine significant figures (10 October 2026).
Celsius and kelvin by the exact offset: Exact rational arithmetic (Python 3.13.16 fractions) on 5 conversions and 2 refusals below absolute zero, exactly as decimal strings (10 October 2026).
- Cases
Unit conversion within one quantity, with molar bridges through a supplied formula weight: No case set is linked to this version.
Celsius and kelvin by the exact offset: No case set is linked to this version.
- Hostile inputs
Sent 27 malformed, extreme and misspelt calls. None broke it, and every call with an undeclared argument, or with text in place of a number or a true/false value, was declined with a reason.
Run 2026-11-12-2 of 12 November 2026, server 0.11.0.
- Same answer
Called twice and with its arguments in another order, it gave the same result.
Run 2026-11-12-2 of 12 November 2026, server 0.11.0.
- Not checked
Unit conversion within one quantity, with molar bridges through a supplied formula weight: Since the 2019 SI the molar mass constant is not exactly 1 g/mol, so reading Da as g/mol is a convention rather than an identity; the size of the difference was not read here (CODATA 2022 not read) and is not carried. No published case set names unit-conversion@1.0.1: its fixtures are not tied to this version by a manifest.
Celsius and kelvin by the exact offset: No published case set names temperature-offset@1.0.0.
What was not checked, in fullfrom the method records
Unit conversion within one quantity, with molar bridges through a supplied formula weight
- Since the 2019 SI the molar mass constant is not exactly 1 g/mol, so reading Da as g/mol is a convention rather than an identity; the size of the difference was not read here (CODATA 2022 not read) and is not carried.
- No published case set names unit-conversion@1.0.1: its fixtures are not tied to this version by a manifest.
- No case runs this method through the served tool on its production runtime.
What this project's records still lack2 things
- A run of the worked example through the tool for both methods.
- A case set linked to this version for both methods.
Cite a number from this toolthe cite line
Every reply carries a cite line naming the tool, the server version, each method with its version and level, and the receipt. Quote it with any number taken from the reply.
calc_unit_conversion, server 1.0.0; unit-conversion@1.0.1 (Checked against a reference); receipt 4fd523641391/ff52379e7c71; methods https://www.drybench.com/methods/calculators; page https://www.drybench.com/methods/tools/calc-unit-conversion. Quote this line with any number taken from this reply.Changes to its methods1 change
- 21 November 2026, unit-conversion@1.0.1: In 1.0.1 such a bridge is worked in exact rational arithmetic on the decimal as typed and the formula weight's exact binary value, then rounded to twelve significant figures as before: the case above now gives 1e-200 M. An answer that is itself outside the normal range of a double is refused with problem magnitude and a stated reason. Every bridge whose double arithmetic stayed in the normal range runs 1.0.0's arithmetic and gives the same answer.