Workflows
These examples show how the native C++ calls combine. Each task links to the page that explains its rules, options, and interface-specific counterparts.
Measure, calculate, and convert
Keep the unit on every intermediate value so dimensional errors are reported near the operation that caused them:
#include <snt/puq/calc/calculator.h>
#include <snt/puq/quantity.h>
snt::puq::Quantity length(2.5, "m");
snt::puq::Quantity width("40*cm");
snt::puq::Quantity area = length * width;
snt::puq::Quantity area_cm2 = area.convert("cm2");
snt::puq::Calculator calculator;
snt::puq::Quantity speed = calculator.eval("12*km / 3*h").value;
Use Concepts and model for arithmetic rules and PUEL calculation for expression evaluation.
Convert between unit systems
Select a system when the unit text alone is ambiguous or when a cross-system conversion needs a physical-quantity context:
#include <snt/puq/quantity.h>
snt::puq::Quantity distance("US_mi");
snt::puq::Quantity distance_km = distance.convert("km");
See Conversion and unit systems for the native conversion rules and the interactive converter.
Inspect a unit expression
When an application validates a unit without evaluating a complete quantity, parse the unit expression directly:
#include <snt/puq/solver/unit_solver.h>
snt::puq::UnitSolver solver;
auto unit = solver.eval("kg*m/s2");
See PUEL calculation for Calculator and UnitSolver details, and the PUEL specification for the language itself.
Model uncertainty
Ordinary arithmetic uses first-order propagation. Distribution-aware sampling is an explicit opt-in operation for nonlinear or correlated inputs. See Concepts and model for the available workflow and its scalar-input restriction.