mpusz / mp-units

The quantities and units library for C++
https://mpusz.github.io/mp-units/
MIT License
994 stars 79 forks source link

ice_point definition is (very very slightly) incorrect #539

Closed chiphogg closed 5 months ago

chiphogg commented 6 months ago

I didn't want to hijack #537, but I noticed this line in it:

https://github.com/mpusz/mp-units/blob/e01942c23b4298ce6ee0f04dfb35de4bf867d2a9/src/systems/si/include/mp-units/systems/si/units.h#L77

The correct definition would set the value to 273.15. This definition sets it to the representable double precision floating point number that is closest to 273.15. Although the difference is extremely tiny, it is enough to prevent valid integer-type-only use cases that use exact reasoning (for example, converting between millikelvins and millidegrees Celsius).

I'm not sure about the absolute best way to proceed, but I bet it would be good to use an integer to define this value rather than floating point.