News for hackers. Stuff that matters.
Re:Improving our safety with a physical quantities and units... by pests on Monday December 25, 2023 @01:50AM (#38760425)
But cant you just implement operator+(celcius, celcius) that will do the conversion to kelvin and back, since you know for certain the conversion math?
Re:Improving our safety with a physical quantities and units... by majorexception on Monday December 25, 2023 @04:36AM (#38761169)
I did that, but then adding 0_degC + 0_degC gave 273.15_degC. I think that would be surprising to many people. In reality I don't remember ever having to deal with physics formulas that used °C instead of Kelvins, so the only time I need to use °C is when presenting the temperature in the UI:

    temperature.in<si::Celsius>()
Re:Improving our safety with a physical quantities and units... by pests on Friday December 29, 2023 @04:54PM (#38810687)
Duh. I was thinking too much on the syntax side and not thinking about the physical world; which is ironic considering the discussion topic.
Re:Improving our safety with a physical quantities and units... by phanimahesh on Monday December 25, 2023 @06:44AM (#38761816)
Adding temperatures is not done usually. Mixing substances adds thermal energy. There's no reason I can hink of why allowing plus operator on temperatures is a good idea. You can add temperature differentials, but it is plain addition so long as units are in agreement. And 0C differential is 0F differential, no offsets in conversions.