Boost logo

Boost :

From: Pavol Droba (droba_at_[hidden])
Date: 2004-11-22 13:09:38


On Mon, Nov 22, 2004 at 09:37:11AM -0700, Jeff Garland wrote:
> On Mon, 22 Nov 2004 16:00:26 +0100, Pavol Droba wrote
> > Hi,
> >
> > In the Date-Time library, date_duration class provides a set of
> > basic arithmetic operations. Among others there is multiplication
> > and division.
> >
> > Current interface supports only integer factors. Sometimes this
> > precision is not sufficient. I have actualy came accross such a
> > occasion. I need to adjust the duration using a multiplier from
> > range <0,1>. Currenly it is not feasible, and I have to workaroud it
> > by converting to microseconds and back.
> >
> > Would it be possible to alter the interface, so it will be able to
> > use real factors?
>
> Well date_duration is meant only to represent whole days, so even if this
> could be supported you would get either rounding or truncation errors. So
> obviously you are making some decisions on this in your user code. Also, is
> there a reason why you aren't just using a time_duration?
>

Oh, sorry, I did mean time_duration. I will give an example.
Imagine, that you have time_duration that spans over multiple years. Internal
ticks_ value is quite large number.

Now lets's say it is 1000000 ... I'd like to multily it by 0.55. It will be
nice integer after the operation. But there is no other reasonable way to do
if otherwise.

Just in case you wondering what can be use case for such an operation, imagine
a graph where x-axis represents a timeline between two timestamps. If you want
to draw a grid, you will need to multiply the time difference by 0.1 0.2 0.3
and etc.

Regards,

Pavol


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk