You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@mesos.apache.org by "Andrew Schwartzmeyer (JIRA)" <ji...@apache.org> on 2018/01/10 00:13:00 UTC

[jira] [Created] (MESOS-8421) Duration operators drop precision, even when used with integers

Andrew Schwartzmeyer created MESOS-8421:
-------------------------------------------

             Summary: Duration operators drop precision, even when used with integers
                 Key: MESOS-8421
                 URL: https://issues.apache.org/jira/browse/MESOS-8421
             Project: Mesos
          Issue Type: Improvement
          Components: stout
            Reporter: Andrew Schwartzmeyer
            Priority: Minor


The implementation of {{Duration operator*=()}} is as follows:

{noformat}
  Duration& operator*=(double multiplier)
  {
    nanos = static_cast<int64_t>(nanos * multiplier);
    return *this;
  }
{noformat}

A similar pattern is implemented for all the operators. This means that, even when multiplying by {{int64_t}} (underlying type of {{nanos}}), we lose precision.

While [Review #64729|https://reviews.apache.org/r/64729/] removes the conversion warnings from {{int}} and {{size_t}} to {{double}}, it purposefully does not address fixing the precision of these operators (as that'll be a change in behavior, albeit slight, and should be done for the whole class at once).



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)