November 06, 2019 Duration to Decimal Total | ||||
---|---|---|---|---|
| ||||
`core.time.Duration` has a `total` function for extracting the value withing the Duration. `total` returns a whole number (`long`). Is there a function that returns a decimal (`double` or `float`)? I cannot find one in `core.time`. How would I do it then? I know I can get finer precision (say msecs) and then divide it to get a courser precision (say secs) but then I might loose some potential accuracy. I could do nsecs but that could be finer than than the actual internal number and therefore cause extra calculation or end up truncating really large numbers. I would think a function that this would be appropriate to belong in the module. Am I missing it? Or, how would you recommend calculating it? tldr: I am looking for a function like `double as(string units)(Duration)`. |
November 06, 2019 Re: Duration to Decimal Total | ||||
---|---|---|---|---|
| ||||
Posted in reply to Jonathan Levi | On Wednesday, 6 November 2019 at 19:13:46 UTC, Jonathan Levi wrote: > I would think a function that this would be appropriate to belong in the module. Am I missing it? Or, how would you recommend calculating it? The author of the module has explained before that this is very intentional: https://forum.dlang.org/post/mailman.3711.1453121204.22025.digitalmars-d-learn@puremagic.com |
Copyright © 1999-2021 by the D Language Foundation