C++ Logo

std-proposals

Advanced search

Re: [std-proposals] On the standardization of mp-units P3045R1

From: Lorand Szollosi <szollosi.lorand_at_[hidden]>
Date: Wed, 19 Jun 2024 09:12:32 +0200
Hi,

> On 19 Jun 2024, at 07:55, Thiago Macieira via Std-Proposals <std-proposals_at_[hidden]> wrote:
>
> And yet it would be the wrong answer *because* it's the wrong math. You can
> multiply 30 by 1.1 but that's not 10% higher temperature where it counts.

Let’s agree that ‘where it counts’ is up to the user. I completely understand the pysics example you gave, but when you’re working in deg_C, I’d argue that it’s not the expectation. It were the expectation had we been working in K. Also, let’s not forget that K itself is already a non-linear unit to measure entropy, the underlying real physical property, so by your logic, multiplying K values won’t fly, either. Hence, we can either skip defining operator* for temperature points (and leave it up to the user), have named multiply functions (e.g., mul_val(double), mul_abs(double), mul_underlying(double), …), or provide value mutiplicationI think.

> The problem is multiplying or dividing a non-absolute quantity. So, would it
> suffice to deny multiplication and divisions of °C and °F quantity points,
> allowing only additions and subtractions to other deltas? Looking at
> std::chrono, you can add two durations together, subtract one from the other,
> you can multiply a duration by a scalar, add a duration to a time_point, or
> subtract one from another (resulting in a duration) but you can't multiply a
> time_point by a scalar or add two time_points together.
time_point is not the same as temperature_point, as others have said before. We agree that it makes little sense to define operator* for a datetime expressed in natural form. It might or might not make sense to define it for Julian dates (e.g. to tell where are we, in percentage, to overflow). For geospatial, it probably makes sense to say, ‘twice the latitude’, but not ‘twice the coordinate’. It surely makes sense to say, ‘twice the (absolute) yield’, or ‘commission is ten percent of the (absolute) dollar amount’, which is not the same as ‘tax is 30% of the (positive part of) dollar amount difference of exit and entry of the position’. Hence, usability of operator* is heavily dependent on the unit.

Thanks,
-lorro

Received on 2024-06-19 07:12:46