Skip to content

Add SI units for new quantities and roundScale utility#14

Merged
gdtroszak merged 3 commits intomainfrom
11-add-si-units-for-additional-quantities-and-common-non-trivial-units
Mar 15, 2026
Merged

Add SI units for new quantities and roundScale utility#14
gdtroszak merged 3 commits intomainfrom
11-add-si-units-for-additional-quantities-and-common-non-trivial-units

Conversation

@gdtroszak
Copy link
Contributor

Adds SI unit modules for the quantities introduced in #10, plus non-trivial units for several existing modules. Each new quantity gets a module with its base SI unit, and quantities with common non-SI-prefix conversions include those as well (e.g., gramPerLiter, revolutionPerMinute, literPerMinute).

New unit modules:

  • density — kilogramPerCubicMeter, gramPerLiter, gramPerCubicCentimeter
  • specificVolume — cubicMeterPerKilogram
  • momentum — newtonSecond
  • angularVelocity — radianPerSecond, revolutionPerMinute
  • angularAcceleration — radianPerSecondSquared
  • torque — newtonMeter
  • dynamicViscosity — pascalSecond
  • kinematicViscosity — squareMeterPerSecond
  • surfaceTension — newtonPerMeter
  • wavenumber — reciprocalMeter
  • heatCapacity — joulePerKelvin
  • specificHeatCapacity — joulePerKilogramKelvin
  • specificEnergy — joulePerKilogram
  • thermalConductivity — wattPerMeterKelvin
  • electricFieldStrength — voltPerMeter
  • permittivity — faradPerMeter
  • permeability — henryPerMeter
  • currentDensity — amperePerSquareMeter
  • volumetricFlowRate — cubicMeterPerSecond, literPerSecond, literPerMinute
  • massFlowRate — kilogramPerSecond
  • concentration — molePerCubicMeter, molePerLiter
  • molarMass — kilogramPerMole, gramPerMole

Additional units for existing modules:

  • velocity — kilometerPerHour
  • charge — ampereHour, milliampereHour
  • pressure — atmosphere
  • area — squareKilometer, squareCentimeter

Composing scale factors from unit properties can introduce IEEE 754 noise (e.g., centimeter.scale ** 3 producing 1.0000000000000002e-6 instead of 1e-6). A new roundScale utility in dim-unit rounds computed factors to 15 significant digits, eliminating these artifacts while preserving all meaningful precision. It's an opt-in call-site tool — scaled() itself is unchanged.

Also aligns the shared-dimension note phrasing in frequency.ts and absorbed-dose.ts to match the new modules.

Closes #11.

Composing scale factors from unit properties (e.g., gram.scale /
centimeter.scale ** 3) can introduce floating-point artifacts. roundScale
rounds to 15 significant digits to eliminate these while preserving all
meaningful precision. Exported from the package root for use at call sites
where composition noise is visible.
Adds unit modules for density, specificVolume, momentum, angularVelocity,
angularAcceleration, torque, dynamicViscosity, kinematicViscosity,
surfaceTension, wavenumber, heatCapacity, specificHeatCapacity,
specificEnergy, thermalConductivity, electricFieldStrength, permittivity,
permeability, currentDensity, volumetricFlowRate, massFlowRate,
concentration, and molarMass. Also adds non-trivial units to existing
modules: kilometerPerHour (velocity), ampereHour/milliampereHour (charge),
atmosphere (pressure), squareKilometer/squareCentimeter (area).

Closes #11
Add ' — the type system cannot distinguish them' to the shared-dimension
notes in frequency.ts and absorbed-dose.ts, matching the phrasing used in
the new angular-velocity, torque, and specific-energy modules.
@gdtroszak gdtroszak self-assigned this Mar 15, 2026
@gdtroszak gdtroszak linked an issue Mar 15, 2026 that may be closed by this pull request
26 tasks
@gdtroszak gdtroszak merged commit 8bc5b56 into main Mar 15, 2026
1 check passed
@gdtroszak gdtroszak deleted the 11-add-si-units-for-additional-quantities-and-common-non-trivial-units branch March 15, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add SI units for additional quantities and common non-trivial units

1 participant