Uploaded image for project: 'Mesos'
  1. Mesos
  2. MESOS-8421

Duration operators drop precision, even when used with integers

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 1.5.0
    • stout
    • None

    Description

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

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

      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 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).

      Attachments

        Activity

          People

            Unassigned Unassigned
            andschwa Andrew Schwartzmeyer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: