[Issue 6725] core.time.dur should accept floating point

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Mon Jul 21 11:56:37 PDT 2014


https://issues.dlang.org/show_bug.cgi?id=6725

--- Comment #10 from Steven Schveighoffer <schveiguy at yahoo.com> ---
(In reply to Jonathan M Davis from comment #9)
> (In reply to Steven Schveighoffer from comment #8)
> > Note, the indicated mechanism to make a proper duration has improved
> > somewhat:
> > 
> > 1.second + 500.msecs + 100.usecs;
> > 
> > I think this still looks awful.
> 
> In most cases, the most that you'd need would be two pieces, not three. And
> I think that that's a small price to pay for avoiding floating point errors.
> 

I was just going by the example you gave. You could do it in 2 pieces, but then
you start getting into much larger numbers:

1.second + 500100.usecs;

But I think there is a over-concern here about floating point conversion. It
can be made to be exact, as long as you are dealing with literals. I remember
running an extensive test back when I was working on the Tango time code. All
you have to do is add an epsilon of .5 hnsecs or something like that.

--


More information about the Digitalmars-d-bugs mailing list