Boost logo

Boost Users :

Subject: Re: [Boost-users] [chrono] float-based milliseconds?
From: Brian Budge (brian.budge_at_[hidden])
Date: 2013-08-30 19:34:06


On Fri, Aug 30, 2013 at 4:26 PM, Michael Powell <mwpowellhtx_at_[hidden]> wrote:
> Hello,
>
> Or any of the chrono-steady-clock-based time units...
>
> I am noticing some what appear to be rounding errors outputting
> resulting millisecond values using the boost::chrono::milliseconds(x).
>
> It's a design-decision, most if not all of our floating-point values
> are single-precision-float, don't need to be double-precision-float.
>
> When we output the milliseconds(x).count() values, however, what I am
> finding is that the values are sometimes inaccurate, the same value in
> 3.0, for instance, output as 2.99995, stuff like this.
>
> Is there a way to tell milliseconds what precision floating point it
> is? float or double?
>
> We are targeting ARM, BTW, without hardware floating point support,
> which is the main reason, I'd like to keep things single-precision
> float, if at all possible.
>

Hi Michael -

I don't know the answer to this question (can chrono be configured to
use doubles); however, I thought it might be useful to point out that
when you're talking about 5 decimal digits of precision at
milliseconds, you're only going to be off by a couple of tens of
nanoseconds, which is likely less than the precision of any timer on
the system.

  Brian


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