Skip to content

Support affine unit conversions (e.g., °C/°F ↔ K) in addition to pure multiplicative scale_to_si #52

Description

@parneetsingh022

Right now Unit assumes purely multiplicative conversions via scale_to_si. That works for most units (m ↔ cm, s ↔ ms, etc.), but fails for affine scales like Celsius and Fahrenheit, where conversion requires an offset (and, for °F, both offset and scale). This makes it impossible to represent absolute temperatures in °C/°F correctly, and it can lead to incorrect arithmetic if users try to “fake” it with only a scale.

Additionally, temperature differences (Δ°C, Δ°F) are multiplicative (no offset), whereas absolute temperatures (°C, °F) are affine. The library should distinguish the two to keep arithmetic valid.

Example:

(35 °C - 25 °C) = 10 °C  = 10 K

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesthelp wantedExtra attention is needed

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions