[Issue 6725] core.time.dur should accept floating point
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Mon Jul 21 12:12:54 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=6725
--- Comment #11 from Jonathan M Davis <jmdavisProg at gmx.com> ---
(In reply to Steven Schveighoffer from comment #10)
> 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;
Yeah. I was just trying to point out that in practice, you pretty much would
just need some number of seconds and the fractional seconds would then probably
just be multiple of 10 of either msecs or usecs. Having to do something like
1.5001 is not likely to be common at all, so if it's a bit uglier, oh well.
> 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.
I'm not opposed to something like durLit!("1.2552", "seconds") which is then
essentially a Duration literal which can be a floating point value. However,
using floating point values for time at runtime is just begging for bugs, and
such code should be avoided with extreme prejudice.
--
More information about the Digitalmars-d-bugs
mailing list