Boost logo

Boost Users :

Subject: Re: [Boost-users] [units] Adding two absolute units
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2015-12-30 12:17:51


AMDG

On 12/30/2015 05:49 AM, Itzik wrote:
>
> Eventually it turned out that I was mistaken with the formula, and
> subtraction was required instead, so there's no problem there.
> Alas, there's also a much simpler use case: What if I want to average the
> temperature of the last N readouts? Shouldn't boost::units support this
> simple operation?
>

There's actually an alternate formula that
does work:

M = 0
For i = 1..N
  M += (X_i - M)/i

  The normal M = \sum X_i / N fails because
of two operators, + and /, not just +. If
you support that, I'm not sure what the point
of using absolute in the first place is.

> I have no formal physics education, but intuitively, adding two absolute
> temperatures doesn't seem really like a mistake to me, even if it's an odd
> thing to do.
>

  In the case of the average, the addition gives
an intermediate result which has no meaning by
itself. This is forbidden by design. If this
isn't what you need, don't use absolute.

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net