Conversion and unit systems

Conversion creates a new Quantity expressed in target units. The original quantity remains unchanged, which makes it safe to retain both a canonical calculation value and a display-specific representation.

Try a conversion

Enter a PUQ quantity expression and target units. This tool runs the same C++ conversion command as snt puq convert in your browser. The optional fields help with units that need an explicit system or physical-quantity context.

Unit systems and quantity context
Enter a conversion and select Convert.

The conversion runs locally in the browser. No expression is sent to a server.

Converting compatible quantities

Pass a target unit expression to Quantity::convert():

#include <snt/puq/quantity.h>

snt::puq::Quantity distance("1 mile");
snt::puq::Quantity distance_km = distance.convert("km");

The target must be dimensionally compatible with the source. PUQ reports an error instead of converting, for example, a length to seconds. The same method can convert derived units such as speed, energy, or pressure.

Systems and contextual conversions

PUQ supports SI, US customary, ESU, and other registered unit systems. Most conversions can infer all required information from the source and target units. Some cross-system conversions need an explicit physical-quantity context; the convert overload accepts a target system and quantity name for that case.

The command-oriented C++ API supports selectable systems, formatted output, and unit-definition lists. See PUQ systems API for the C++ system and conversion classes.